Difference between revisions of "API Collections Manage Users"
Tommy.leung (Talk | contribs) (→Example) |
Tommy.leung (Talk | contribs) (→Examples) |
||
Line 74: | Line 74: | ||
== Examples == | == Examples == | ||
− | + | ''these example require jQuery'' | |
− | Add | + | === Add new users 1, 2, 3 === |
− | + | ||
− | + | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 84: | Line 82: | ||
! Paramater | ! Paramater | ||
! Value | ! Value | ||
+ | |- | ||
+ | | token | ||
+ | | 1f0qpLwoV5oIcfnU2yvO | ||
|- | |- | ||
| ids[] | | ids[] | ||
− | | [1,2, | + | | [1,2,3] |
|} | |} | ||
− | + | {| class="wikitable collapsible collapsed" | |
+ | |- | ||
+ | ! jQuery ajax call | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <nowiki> | ||
+ | $.ajax('http://api.unroole.com/collections/2/update_users?token=1f0qpLwoV5oIcfnU2yvO', { | ||
+ | headers: { | ||
+ | // use below for json request | ||
+ | Accept : "application/json, text/javascript" | ||
+ | // use below for xml request | ||
+ | //Accept : "text/html,application/xhtml+xml,application/xml" | ||
+ | }, | ||
+ | type: 'POST', | ||
+ | data: { | ||
+ | ids: [1,2,3], | ||
+ | filter_ids: [], | ||
+ | } | ||
+ | }); | ||
+ | </nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! JSON | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | {"added_users":[1,2,3],"deleted_users":[],"rejected_users":[],"http_status":200} | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! XML | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <hash> | ||
+ | <added-users type="array"> | ||
+ | <added-user type="integer">1</added-user> | ||
+ | <added-user type="integer">2</added-user> | ||
+ | <added-user type="integer">3</added-user> | ||
+ | </added-users> | ||
+ | <deleted-users type="array"/> | ||
+ | <rejected-users type="array"/> | ||
+ | <http-status type="integer">200</http-status> | ||
+ | </hash> | ||
+ | </blockquote> | ||
+ | |} | ||
=== Delete users === | === Delete users === |
Revision as of 14:56, 27 June 2012
Contents
Summary
Allows for managing users in a collection.
URI
https://api.unroole.com/collections/[collection-id]/update_users
HTTP Method
POST
Required Paramaters
Paramater | Default | Maximum Length | Accepted Values | Description |
---|---|---|---|---|
token | API Persistence Token that identifies this user and its permissions. |
Optional Paramaters
Paramater | Default | Maximum Length | Accepted Values | Description |
---|---|---|---|---|
ids[] | Array of integers | Array of mobile briefcase users ids to add. | ||
filter_ids[] | All users belonging to that account. | Array of integers | Array of mobile briefcase users ids to act upon. This list should be a subset of the mobile briefcase users on the account, so that only SOME of the mobile briefcase users on the account will be affected. If there are extra ids in this list, which are NOT in the ids[] list, then those will be deleted from this collection. |
Response
Field | Type | Description |
---|---|---|
http_status | integer | API Status Code http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html |
error | Rails default | |
added_users | array of ids | List of users that were successfully added to the collection. |
deleted_users | array of ids | List of users that were successfully deleted from the collection. |
rejected_users | array of ids | List of users that failed to be added or delete. Mostly likely the user does not belong to this account. |
Examples
these example require jQuery
Add new users 1, 2, 3
Paramater | Value |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
ids[] | [1,2,3] |
jQuery ajax call |
---|
|
JSON |
---|
|
XML |
---|
|
Delete users
Delete Users: 3, 45, 85
Request:
Paramater | Value |
---|---|
filter_ids[] | [3,45,85] |
Response:
Delete all users
Delete all users from the collection.
Request:
No parameters need to be sent.
Response:
Add and remove users
Add Users: 1, 10, 12
Delete Users: 2, 6, 8
Request:
Paramater | Value |
---|---|
ids[] | [1,10,12] |
filter_ids[] | [1,2,6,8,10,12] |
Response: