Difference between revisions of "API Collections Create"
Tommy.leung (Talk | contribs) |
Tommy.leung (Talk | contribs) (→Example) |
||
(One intermediate revision by one user not shown) | |||
Line 128: | Line 128: | ||
<id type="integer">11</id> | <id type="integer">11</id> | ||
<http-status type="integer">200</http-status> | <http-status type="integer">200</http-status> | ||
+ | </hash> | ||
+ | </nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | === Create a playlist collection with rotation speed 30, activating today and never deactivating === | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Parameters | ||
+ | ! Values | ||
+ | |- | ||
+ | | token | ||
+ | | 1f0qpLwoV5oIcfnU2yvO | ||
+ | |- | ||
+ | | name | ||
+ | | 'sample collection' | ||
+ | |- | ||
+ | | active | ||
+ | | true | ||
+ | |- | ||
+ | | activate_at | ||
+ | | (new Date()).toISOString() | ||
+ | |- | ||
+ | | disable_deactivation | ||
+ | | true | ||
+ | |- | ||
+ | | playlist | ||
+ | | true | ||
+ | |- | ||
+ | | rotation_speed | ||
+ | | 30 | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! jQuery ajax call | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <nowiki> | ||
+ | $.ajax('http://api.unroole.com/channels/1/collections?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: { | ||
+ | name: 'sample collection', | ||
+ | active: true, | ||
+ | activate_at: (new Date()).toISOString(), | ||
+ | disable_deactivation: true, | ||
+ | playlist: true, | ||
+ | rotation_speed: 30 | ||
+ | } | ||
+ | </nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! JSON | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <nowiki>{"id":18,"http_status":200}</nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! XML | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <nowiki> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <hash> | ||
+ | <id type="integer">17</id> | ||
+ | <http-status type="integer">200</http-status> | ||
+ | </hash> | ||
+ | </nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | === Error because name and dates not set === | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! Parameters | ||
+ | ! Values | ||
+ | |- | ||
+ | | token | ||
+ | | 1f0qpLwoV5oIcfnU2yvO | ||
+ | |- | ||
+ | | name | ||
+ | | '' | ||
+ | |- | ||
+ | | active | ||
+ | | true | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! jQuery ajax call | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <nowiki> | ||
+ | $.ajax('http://api.win-tommy.com:3000/channels/1/collections?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: { | ||
+ | name: '', | ||
+ | active: true | ||
+ | } | ||
+ | }); | ||
+ | </nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! JSON | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <nowiki> | ||
+ | { "error" : { "active" : [ "The dates for which collections is active has not been set" ], | ||
+ | "name" : [ "can't be blank" ] | ||
+ | }, | ||
+ | "http_status" : 412 | ||
+ | } | ||
+ | </nowiki> | ||
+ | </blockquote> | ||
+ | |} | ||
+ | |||
+ | {| class="wikitable collapsible collapsed" | ||
+ | |- | ||
+ | ! XML | ||
+ | |- | ||
+ | | <blockquote> | ||
+ | <nowiki> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <hash> | ||
+ | <error> | ||
+ | <error>Name can't be blank</error> | ||
+ | <error>Active The dates for which collections is active has not been set</error> | ||
+ | </error> | ||
+ | <http-status type="integer">412</http-status> | ||
</hash> | </hash> | ||
</nowiki> | </nowiki> | ||
</blockquote> | </blockquote> | ||
|} | |} |
Latest revision as of 11:12, 27 June 2012
Contents
Summary
Allows for creating a new collection.
URI
https://api.unroole.com/channels/[channel-id]/collections
HTTP Method
POST
Required Paramaters
Paramater | Default | Maximum Length | Accepted Values | Description |
---|---|---|---|---|
token | API Persistence Token that identifies this user and its permissions. | |||
name | 255 | string (length > 0) | Name of the collection. |
Optional Paramaters
Paramater | Default | Maximum Length | Accepted Values | |
---|---|---|---|---|
description | MySQL TEXT UTF-8 | The description of the collection. | ||
active | false | boolean | Make the playlist active or deactivate (dis-regardless of the active/deactivate date). | |
activate_at | ISO 8061 date | This is required if collection is set to active | ||
deactivate_at | ISO 8061 date | This is required if collection is set to active and does not disable deactivation | ||
disable_deactivation | boolean | Disable the deactivation date so that the collection will never expire. | ||
playlist | false | boolean | Whether the collection is a slideshow | |
rotation_speed | 0 - 900 | The time between the items in the collection playing as a slideshow (in seconds). Only valid when collection is set to a playlist. |
Response
Field | Type | Description |
---|---|---|
http_status | integer | API Status Code http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html |
error | Rails default | |
id | integer | The id of the collection if created successfully. |
Example
these example require jQuery
Create a collection activating today and deactivating the next day
Parameters | Values |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
name | 'test collection' |
description | 'some description' |
active | true |
activate_at | (new Date()).toISOString() |
deactivate_at | (new Date((new Date()).setDate((new Date()).getDate() +1))).toISOString() |
jQuery ajax call |
---|
|
JSON |
---|
|
XML |
---|
|
Create a playlist collection with rotation speed 30, activating today and never deactivating
Parameters | Values |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
name | 'sample collection' |
active | true |
activate_at | (new Date()).toISOString() |
disable_deactivation | true |
playlist | true |
rotation_speed | 30 |
jQuery ajax call |
---|
|
JSON |
---|
|
XML |
---|
|
Error because name and dates not set
Parameters | Values |
---|---|
token | 1f0qpLwoV5oIcfnU2yvO |
name | |
active | true |
jQuery ajax call |
---|
|
JSON |
---|
|
XML |
---|
|