Difference between revisions of "API Collections Manage Users"
Tommy.leung (Talk | contribs) (→URI) |
Tommy.leung (Talk | contribs) (→Examples) |
||
(9 intermediate revisions by one user not shown) | |||
Line 4: | Line 4: | ||
== URI == | == URI == | ||
− | {{:API_Base_URI}} | + | {{:API_Base_URI}}collections/[collection-id]/update_users |
== HTTP Method == | == HTTP Method == | ||
Line 37: | Line 37: | ||
! Description | ! Description | ||
|- | |- | ||
− | | | + | | ids[] |
| | | | ||
| | | | ||
Line 43: | Line 43: | ||
| Array of mobile briefcase users ids to add. | | Array of mobile briefcase users ids to add. | ||
|- | |- | ||
− | | | + | | filter_ids[] |
| All users belonging to that account. | | All users belonging to that account. | ||
| | | | ||
| Array of integers | | 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 | + | | 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. |
|} | |} | ||
Line 67: | Line 67: | ||
| List of users that were successfully deleted from the collection. | | List of users that were successfully deleted from the collection. | ||
|- | |- | ||
− | | | + | | rejected_users |
− | | array of | + | | array of ids |
− | | List of users that failed to be added or delete. | + | | List of users that failed to be added or delete. <br/> There are several possibilities for a rejected user: <br/> * the user does not belong to this account. <br/> * the user was not part of the filter_ids list. <br/> * the user was not in the original list so it could not be deleted. |
|} | |} | ||
− | == | + | == Examples == |
− | + | ||
− | + | ''these example require jQuery'' | |
+ | |||
+ | === Add new users 1, 2, 3 === | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Paramater | ||
+ | ! Value | ||
+ | |- | ||
+ | | token | ||
+ | | 1f0qpLwoV5oIcfnU2yvO | ||
+ | |- | ||
+ | | ids[] | ||
+ | | [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 2, 3 === | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Paramater | ||
+ | ! Value | ||
+ | |- | ||
+ | | token | ||
+ | | 1f0qpLwoV5oIcfnU2yvO | ||
+ | |- | ||
+ | | filter_ids[] | ||
+ | | [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: [], | ||
+ | filter_ids: [2,3] | ||
+ | } | ||
+ | }); | ||
+ | </nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! JSON | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | {"added_users":[],"deleted_users":[2,3],"rejected_users":[],"http_status":200} | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! XML | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <hash> | ||
+ | <added-users type="array"/> | ||
+ | <deleted-users type="array"> | ||
+ | <deleted-user type="integer">2</deleted-user> | ||
+ | <deleted-user type="integer">3</deleted-user> | ||
+ | </deleted-users> | ||
+ | <rejected-users type="array"/> | ||
+ | <http-status type="integer">200</http-status> | ||
+ | </hash> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | === Delete all users === | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Paramater | ||
+ | ! Value | ||
+ | |- | ||
+ | | token | ||
+ | | 1f0qpLwoV5oIcfnU2yvO | ||
+ | |} | ||
+ | |||
+ | {| 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: [], | ||
+ | filter_ids: [] | ||
+ | } | ||
+ | }); | ||
+ | </nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! JSON | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | {"added_users":[],"deleted_users":[1,2,3,4,5],"rejected_users":[],"http_status":200} | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! XML | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <hash> | ||
+ | <added-users type="array"/> | ||
+ | <deleted-users type="array"> | ||
+ | <deleted-user type="integer">1</deleted-user> | ||
+ | <deleted-user type="integer">2</deleted-user> | ||
+ | <deleted-user type="integer">3</deleted-user> | ||
+ | <deleted-user type="integer">4</deleted-user> | ||
+ | <deleted-user type="integer">5</deleted-user> | ||
+ | </deleted-users> | ||
+ | <rejected-users type="array"/> | ||
+ | <http-status type="integer">200</http-status> | ||
+ | </hash> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | === Add and delete users === | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Paramater | ||
+ | ! Value | ||
+ | |- | ||
+ | | token | ||
+ | | 1f0qpLwoV5oIcfnU2yvO | ||
+ | |- | ||
+ | | ids[] | ||
+ | | [3,4] | ||
+ | |- | ||
+ | | filter_ids[] | ||
+ | | [1,2,3,4] | ||
+ | |} | ||
+ | |||
+ | {| 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: [3,4], | ||
+ | filter_ids: [1,2,3,4] | ||
+ | } | ||
+ | }); | ||
+ | </nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! JSON | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | {"added_users":[3,4],"deleted_users":[1,2],"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">3</added-user> | ||
+ | <added-user type="integer">4</added-user> | ||
+ | </added-users> | ||
+ | <deleted-users type="array"> | ||
+ | <deleted-user type="integer">1</deleted-user> | ||
+ | <deleted-user type="integer">2</deleted-user> | ||
+ | </deleted-users> | ||
+ | <rejected-users type="array"/> | ||
+ | <http-status type="integer">200</http-status> | ||
+ | </hash> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | === Rejected users that do not belong to the account === | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Paramater | ||
+ | ! Value | ||
+ | |- | ||
+ | | token | ||
+ | | 1f0qpLwoV5oIcfnU2yvO | ||
+ | |- | ||
+ | | ids[] | ||
+ | | [77] | ||
+ | |- | ||
+ | | filter_ids[] | ||
+ | | [88,99] | ||
+ | |} | ||
+ | |||
+ | {| 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: [77], | ||
+ | filter_ids: [88,99] | ||
+ | } | ||
+ | }); | ||
+ | </nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! JSON | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | {"added_users":[],"deleted_users":[],"rejected_users":[77,88,99],"http_status":200} | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! XML | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <hash> | ||
+ | <added-users type="array"/> | ||
+ | <deleted-users type="array"/> | ||
+ | <rejected-users type="array"> | ||
+ | <rejected-user type="integer">77</rejected-user> | ||
+ | <rejected-user type="integer">88</rejected-user> | ||
+ | <rejected-user type="integer">99</rejected-user> | ||
+ | </rejected-users> | ||
+ | <http-status type="integer">200</http-status> | ||
+ | </hash> | ||
+ | </blockquote> | ||
+ | |} |
Latest revision as of 15:47, 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. There are several possibilities for a rejected user: * the user does not belong to this account. * the user was not part of the filter_ids list. * the user was not in the original list so it could not be deleted. |
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 2, 3
Paramater | Value |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
filter_ids[] | [2,3] |
jQuery ajax call |
---|
|
JSON |
---|
|
XML |
---|
|
Delete all users
Paramater | Value |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
jQuery ajax call |
---|
|
JSON |
---|
|
XML |
---|
|
Add and delete users
Paramater | Value |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
ids[] | [3,4] |
filter_ids[] | [1,2,3,4] |
jQuery ajax call |
---|
|
JSON |
---|
|
XML |
---|
|
Rejected users that do not belong to the account
Paramater | Value |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
ids[] | [77] |
filter_ids[] | [88,99] |
jQuery ajax call |
---|
|
JSON |
---|
|
XML |
---|
|