Syncd API
Activity Assignments
Activity assignments link a user or group (including "all users") to an activity or all activities.
You can check if activities are enabled using the Account Information interface (account / time-settings / show-activities
). Administrators can enable activities from Syncd's web interface via Settings / Time Tracking.
Only Activity Managers can view, create and delete activity assignments. If you'd like to view assigned activities instead of activity assignments, use the Activities interface.
Show
Request
GET /activity_assignments/#{activity-assignment-id}.xml
Optional parameters
The following optional parameters can be used to include extra data:
include=[users, user_groups, activities]
Response
Status: 200 OK <activity-assignment> <id type="integer">#{activity-assignment-id}</id> <!-- if assigned to all users ---> <users>all</users> <!-- else if assigned to a user --> <!-- if include=users --> <user> ... </user> <!-- else --> <user-id type="integer">#{user-id}</user-id> <!-- end --> <!-- else if assigned to a user group ---> <!-- if include=user_groups --> <user-group> ... </user-group> <!-- else --> <user-group-id type="integer">#{user-group-id}</user-group-id> <!-- end --> <!-- end --> <!-- if assigned to all activities ---> <activities>all</activities> <!-- else if include=activities --> <activity> ... </activity> <!-- else --> <activity-id type="integer">#{activity-id}</activity-id> <!-- end --> <!-- if include=timestamps --> <created-at type="datetime">2008-01-08T03:47:52Z</created-at> <updated-at type="datetime">2008-01-08T03:47:52Z</updated-at> <!-- end --> </activity-assignment>
List
Request
All activity assignments:
GET /activity_assignments.xml
Assignments related to a particular activity (includes assignments to all activities):
GET /activities/#{activity-id}/assignments.xml
Direct assignments to a particular activity (excludes assignments to all activities):
GET /activities/#{activity-id}/assignments/direct.xml
Assignments related to a particular user (includes assignments to the user's groups and all users):
GET /users/#{user-id}/activity_assignments.xml
Direct assignments to a particular user (excludes assignments to the user's groups and all users):
GET /users/#{user-id}/activity_assignments/direct.xml
Assignments for a particular user group:
GET /user_groups/#{user-group-id}/activity_assignments.xml
Since all assignments to user groups are direct, there's no separate method for requesting only direct assignments.
Optional parameters
Specify start
and end
to request a specific range of items. For example:
GET /activity_assignments.xml?start=1&end=4
The following optional parameters can be used to include extra data:
include=[users, user_groups, activities]
For example:
GET /activity_assignments.xml?include=users,user_groups,activities
Response
Status: 200 OK <activity-assignments type="array"> <activity-assignment> ... </activity-assignment> ... </activity-assignments>
Create
Request
POST /activity_assignments.xml
Include the following data with your request:
<activity-assignment> <!-- A user, user group, or all users must be included --> <!-- To specify a user: --> <user-id>#{user-id}</user-id> <!-- To specify a user group: --> <user-group-id>#{user-group-id}</user-group-id> <!-- To specify all users: --> <users>all</users> <!-- An activity or all activities must be included --> <!-- To specify an activity: --> <activity-id>#{activity-id}</activity-id> <!-- To specify all activities: --> <activities>all</activities> </activity-assignment>
For example, to assign a user to a specific activity:
<activity-assignment> <user-id>25</user-id> <activity-id>14</activity-id> </activity-assignment>
Response
Status: 201 Created <activity-assignment> <id type="integer">#{new-activity-assignment-id}</id> <user-id type="integer">25</user-id> <activity-id type="integer">14</activity-id> <!-- if include=timestamps --> <created-at type="datetime">2008-01-08T03:47:52Z</created-at> <updated-at type="datetime">2008-01-08T03:47:52Z</updated-at> <!-- end --> </activity-assignment>
Delete
Request
DELETE /activity_assignments/#{activity-assignment-id}.xml
Response
Status: 200 OK