Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postAssignment() #1

Open
sviriden opened this issue Apr 3, 2018 · 5 comments
Open

postAssignment() #1

sviriden opened this issue Apr 3, 2018 · 5 comments
Labels

Comments

@sviriden
Copy link

sviriden commented Apr 3, 2018

Hi,

Do you have any code example how to get work postAssignment() method?
What should I pass as $data parameter?

@jschroed91
Copy link
Member

Hi @sviriden - I will provide an example tomorrow morning

@jschroed91
Copy link
Member

Actually @sviriden I have a code sample I used in another project that I can post here...

    protected function createAssignment($userId, $projectId, $startDate, $endDate, $allocation)
    {
        $data = array(
            'assignment' => array(
                'allocation' => $allocation, // Harvest is in hours, forecast requires seconds.
                'end_date' => $endDate,
                'person_id' => (string) $userId,
                'project_id' => (string) $projectId,
                'repeated_assignment_set_id' => null,
                'start_date' => $startDate,
            ),
        );
        echo "\nCreate assignment";
        $response = $this->forecast->postAssignment($data);
        $assignment = $response['assignment'];
        return $assignment;
    }

@jschroed91
Copy link
Member

I'll leave this issue open until we have documentation written that covers this

@jschroed91
Copy link
Member

Oh, that project that uses this is public, too - if you want some additional examples https://github.com/caxy/harvest-forecast-sync/blob/master/src/Service/SyncService.php

@sviriden
Copy link
Author

sviriden commented Apr 3, 2018

Thanks a lot! Now everything works.

@sviriden sviriden closed this as completed Apr 3, 2018
@sviriden sviriden reopened this Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants