Class: Episodic::Platform::QueryMethods

Inherits:
Base
  • Object
show all
Defined in:
lib/episodic/platform/query_methods.rb

Overview

Class for making requests against the Episodic Platform Query API.

Class Method Summary collapse

Methods inherited from Base

construct_url

Class Method Details

.episodes(options = {}) ⇒ Object

Queries for episodes in your network. The options parameter allows you to limit your results. Acceptable options are:

show_id - A single id or an Array of show ids.  If this param is not provided then 
    all shows in your network are queried.
id - A single id or an Array of episode ids.  If this param is not provided then 
    all episodes in the your network or specified shows are queried.
search_term - This string is used to perform a keywords search against the title, 
    description, tags and custom fields of an episode. Tags should be separated by
    commas.
search_type - The search_type parameter must be one of "tags", "name_description" 
    or "all". The default is "all" 
tag_mode - The tag_mode parameter can be "any" for an OR combination of tags, or 
    "all" for an AND combination. The default is "any". This parameter is ignored if 
    the search_type is not "tags".
status - The status parameter can be used to limit the list of episodes with a 
    certain publishing status. The value must be a comma delimited list of one or more 
    of "off_the_air", "publishing", "on_the_air", "waiting_to_air", "publish_failed"
sort_by - The sort_by parameter is optional and specifies a field to sort the results 
    by. The value must be one of "updated_at", "created_at", "air_date" or "name". 
    The default is "created_at".
sort_dir - The sort_dir parameter is optional and specifies the sort direction. The 
    value must be one of "asc" or "desc". The default is "asc". 
include_views - A value that must be one of "true" or "false" to indicate if total 
    views and complete views should be included in the response. The default is "false". 
    NOTE: Setting this to "true" may result in slower response times.  
page - A value that must be an integer indicating the page number to return the results 
    for. The default is 1.
per_page - A value that must be an integer indicating the number of items per page. The 
    default is 20. NOTE: The smaller this value is the better your response times will be. 
embed_width - An integer value in pixels that specifies the width of the player. The 
    returned embed code width may be larger that this to account for player controls 
    depending on the player you are using. If only the width is provided, the height is 
    determined by maintaining the aspect ratio.
embed_height - An integer value in pixels that specifies the height of the player. The 
    embed code height may be larger that this to account for player controls depending on 
    the player you are using. The default height is 360.

Parameters

options<Hash>

A hash of optional attributes.

Returns

::Episodic::Platform::EpisodesResponse

The parsed response.



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/episodic/platform/query_methods.rb', line 58

def episodes options = {}
  
  # Clone the options into our params hash
  params = options.clone
  
  # Make the request
  response = connection.do_get(construct_url("query", "episodes"), params)
  
  # Convert to a hash
  return parse_episodes_response(response)
end

.modification_callbacks(since, options = {}) ⇒ Object

Third-party applications can register to be notified of changes to episodes and playlists in their network by providing an Modification URL in their network settings. When an episode/playlist is created, modified or deleted the Episodic System when make a POST request to specified URL with an XML representation of the modified object.

This method allows the caller to query for all callbacks registered since a specified time. Although, failed callbacks are marked as failed and retried, this method allows the caller to see a history of callbacks to perhaps reprocess them if something went wrong with their initial processing.

Acceptable filter options are:

pending_only - Set this parameter to 'true' if only unprocessed callbacks should be 
    returned. The default is 'false'. 
page - A value that must be an integer indicating the page number to return the results 
    for. The default is 1.
per_page - A value that must be an integer indicating the number of items per page. The 
    default is 20. NOTE: The smaller this value is the better your response times will be.

Parameters

since<Time>

All callbacks registered since the provided date will be included in the

response.
options<Hash>

A hash of optional attributes.

Returns

String

The XML response from the server.



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/episodic/platform/query_methods.rb', line 99

def modification_callbacks since, options = {}
  
  # Clone the options into our params hash
  params = options.clone
   params[:since] = since
  
  # Make the request
  response = connection.do_get(construct_url("query", "modification_callbacks"), params)
  
  # Convert to a hash
  return response.body
end

.playlists(options = {}) ⇒ Object

Queries for playlists in your network. The options parameter allows you to limit your results. Acceptable options are:

show_id - A single id or an Array of show ids.  If this param is not provided then 
    all shows in your network are queried.
id - A single id or an Array of playlist ids.  If this param is not provided then 
    all playlists in the your network or specified shows are queried.
search_term - This string is used to perform a keywords search against the title, 
    description, and custom fields of a playlist. 
sort_by - The sort_by parameter is optional and specifies a field to sort the results 
    by. The value must be one of "updated_at", "created_at", "name". 
    The default is "created_at".
sort_dir - The sort_dir parameter is optional and specifies the sort direction. The 
    value must be one of "asc" or "desc". The default is "asc".   
page - A value that must be an integer indicating the page number to return the results 
    for. The default is 1.
per_page - A value that must be an integer indicating the number of items per page. The 
    default is 20. NOTE: The smaller this value is the better your response times will be. 
embed_width - An integer value in pixels that specifies the width of the player. The 
    returned embed code width may be larger that this to account for player controls 
    depending on the player you are using. If only the width is provided, the height is 
    determined by maintaining the aspect ratio.
embed_height - An integer value in pixels that specifies the height of the player. The 
    embed code height may be larger that this to account for player controls depending on 
    the player you are using. The default height is 360.

Parameters

options<Hash>

A hash of optional attributes.

Returns

::Episodic::Platform::PlaylistsResponse

The parsed response.



146
147
148
149
150
151
152
153
154
155
156
# File 'lib/episodic/platform/query_methods.rb', line 146

def playlists options = {}
  
  # Clone the options into our params hash
  params = options.clone
  
  # Make the request
  response = connection.do_get(construct_url("query", "playlists"), params)
  
  # Convert to a hash
  return parse_playlists_response(response)
end

.shows(options = {}) ⇒ Object

Queries for shows in your network. The options parameter allows you to limit your results. Acceptable options are:

id - A single id or an Array of episode ids.  If this param is not provided then 
    all shows in the your network or specified shows are queried.
sort_by - The sort_by parameter is optional and specifies a field to sort the results 
    by. The value must be one of "updated_at", "created_at" or "name". The 
    default is "created_at". 
sort_dir - The sort_dir parameter is optional and specifies the sort direction. The 
    value must be one of "asc" or "desc". The default is "asc". 
page - A value that must be an integer indicating the page number to return the results 
    for. The default is 1.
per_page - A value that must be an integer indicating the number of items per page. The 
    default is 20. NOTE: The smaller this value is the better your response times will be.

Parameters

options<Hash>

A hash of optional attributes.

Returns

::Episodic::Platform::ShowsResponse

The parsed response.



181
182
183
184
185
186
187
188
189
190
191
# File 'lib/episodic/platform/query_methods.rb', line 181

def shows options = {}
  
  # Clone the options into our params hash
  params = options.clone
  
  # Make the request
  response = connection.do_get(construct_url("query", "shows"), params)
  
  # Convert to a hash
  return parse_shows_response(response)
end