For all the API calls, you must first obtain an access token. The access token is used to create an instance of the SDK which allows you to access the SDk methods.
Code Sample
SdkClient.new(session[:access_token])
add_playlist_item
add_playlist_item
allows a client to add a single or multiple items to a playlist.
Required Parameters
playlistUid
– Unique id of a specified playlist.add
– An array of paths to the playlist items.Parameter Request Format
{
"add": [
"string"
]
}
Code Sample
begin
playlistUid = params[:playlistUid] || '/'
path = params[:path] || '/'
path = path.split(',')
playlistitemdata = {"add"=> path}
playlistitemdata = JSON.generate(playlistitemdata)
entry = client.add_playlist_item(playlistUid,playlistitemdata)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{h path}"
else
return html_page "Sdk API error #{e}"
end
end
create_playlist
create_playlist
creates a playlist, with or without items.
Required Parameters
name
– The name of a playlistpaths
– An array of paths to items in a playlisttype
– The type of the playlist, such as:Parameter Request Format
{
"name": "string",
"paths": [
"string"
],
"type": "string"
}
Code Sample
begin
playlistdata = {"name"=> name, "paths"=> path, "type"=> type}
playlistdata = JSON.generate(playlistdata)
entry = client.create_playlist(playlistdata)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{h path}"
else
return html_page "Sdk API error #{e}"
end
end
Example Return Response
{
"paths": ["string"]
}
deletePlaylist
deletePlaylist
deletes a specified playlist.
Required Parameters
playlistUid
– Unique ID of the specified playlist.Code Sample
begin
entry = client.deletePlaylist(playlistUid)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{h path}"
else
return html_page "Sdk API error #{e}"
end
end
deletePlaylistItem
deletePlaylistItem
allows a client to remove a single item from a playlist.
Required Parameters
playlistUid
– Unique ID of the specified playlist.itemUid
– Unique id of the specified item in a playlist.Code Sample
begin
playlistUid = params[:playlistUid] || ''
itemUid = params[:itemUid] || ''
entry = client.deletePlaylistItem(playlistUid,itemUid)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{h path}"
else
return html_page "Sdk API error #{e}"
end
end
playlistContent
playlistContent
returns the content of a playlist at the specified path.
Required Parameters
playlistUid
– Unique ID of the specified playlistitemUid
– Unique ID of the specific item in a playlist.Code Sample
begin
entry = client.playlistContent(playlistUid,itemUid)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{e}"
else
return html_page "Sdk API error #{e}"
end
end
playlistDefinition
playlistDefinition
returns the definition of the specified playlist.
Required Parameters
playlistUid
– Unique ID of the specified playlist.Code Sample
begin
entry = client.playlistDefinition(playlistUid)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{h path}"
else
return html_page "Sdk API error #{e}"
end
end
Example Return Response
{
"uid": "string",
"name": "string",
"type": "string",
"mimeTypeRegex": "string",
"paths": ["string"],
"creationDate": "string",
"lastModifiedDate": "string",
"uri": "string",
"shareAssociation": [{
"uid": "string",
"visibility": "string",
"name": "string",
"type": "string"
}]
}
playlistItems
playlistItems
retrieves a list of items in a specified playlist.
Required Parameters
playlistUid
– Unique ID of the specified playliststart
- Starting point for partial responses for folder requests. Default is 1.count
- Maximum items to include in a paginated response for folder requests. Required, if start
is specified.sort
- Specifies sort order for the response. Syntax is {field}+{asc|desc}
. Valid values for field
are:Code Sample
begin
entry = client.playlistItems(playlistUid)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{h path}"
else
return html_page "Sdk API error #{e}"
end
end
Example Return Response
[{
"filename": "string",
"path": "string",
"mimeType": "string",
"size": 0,
"versionCreated": "string",
"fileAttribute": {},
"contentToken": "string",
"checksum": "string",
"contentAccessible": true,
"extension": "string",
"tags": {},
"uri": "string"
}]
playlists
playlists
retrieves a list of playlists for a specified user.
Required Parameters
type
– The type of the playlist, such as:start
- Starting point for partial responses for folder requests. Default is 1.count
- Maximum items to include in a paginated response for folder requests. Required, if start
is specified.sort
- Specifies sort order for the response. Syntax is {field}+{asc|desc}
. Valid values for field
are:Code Sample
begin
entry = client.playlists()
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{h path}"
else
return html_page "Sdk API error #{e}"
end
end
Example Return Response
[{
"uid": "string",
"name": "string",
"type": "string",
"mimeTypeRegex": "string",
"paths": ["string"],
"creationDate": "string",
"lastModifiedDate": "string",
"uri": "string",
"shareAssociation": [{
"uid": "string",
"visibility": "string",
"name": "string",
"type": "string"
}]
}]
update_playlist
update_playlist
allows a client to update a playlist by sending a new ‘playlistDefinition’ model.
Required Parameters
playlistUid
– Unique ID of a specified playlist.name
– Name of the playlist.paths
– An array of paths to items.type
– The type of the playlist, such as:Parameter Request Format
{
"name": "string",
"paths": [
"string"
],
"type": "string"
}
Code Sample
begin
playlistUid = params[:playlistUid] || '/'
name = params[:name] || ''
type = params[:type] || ''
playlistupdatedata = {"name"=> name, "type"=> type}
playlistupdatedata = JSON.generate(playlistupdatedata)
entry = client.update_playlist(playlistUid,playlistupdatedata)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{e}"
else
return html_page "Sdk API error #{e}"
end
end
Example Return Response
{
"uid": "string",
"name": "string",
"type": "string",
"mimeTypeRegex": "string",
"paths": ["string"],
"creationDate": "string",
"lastModifiedDate": "string",
"uri": "string",
"shareAssociation": [{
"uid": "string",
"visibility": "string",
"name": "string",
"type": "string"
}]
}
update_playlist_items
update_playlist_items
allows a client to update a playlist’s name.
Required Parameters
playlistUid
– Unique ID of a specified playlist.name
– Name of the playlist.type
– The type of the playlist, such as:Parameter Request Format
{
"name": "string",
"type": "string"
}
Code Sample
begin
updateplaylistdata = {"name"=> name, "paths"=> path, "type"=> type}
updateplaylistdata = JSON.generate(updateplaylistdata)
entry = client.update_playlist_items(playlistUid,updateplaylistdata)
rescue SdkAuthError => e
session.delete(:access_token) # An auth error means the access token is probably bad
return html_page "Sdk auth error"
rescue SdkError => e
if e.http_response.code == '404'
return html_page "Path not found: #{h path}"
else
return html_page "Sdk API error #{e}"
end
end
Example Return Response
{
"uid": "string",
"name": "string",
"type": "string",
"mimeTypeRegex": "string",
"paths": ["string"],
"creationDate": "string",
"lastModifiedDate": "string",
"uri": "string",
"shareAssociation": [{
"uid": "string",
"visibility": "string",
"name": "string",
"type": "string"
}]
}
Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.