Class: PlatformLib::MediaService
- Inherits:
-
Object
- Object
- PlatformLib::MediaService
- Includes:
- ServiceBase
- Defined in:
- lib/platform_lib/media_service.rb
Overview
Public: A wrapper around the Media Data Service
Examples:
# the preferred method
service = PlatformLib::DataService.new("user", "pass").media_service
# direct instantiation
service = PlatformLib::MediaService.new("auth_token")
Constant Summary collapse
- END_POINT =
"http://data.media.theplatform.com/media/data/Media"
Instance Method Summary collapse
-
#get_media_items(params = {}, &block) ⇒ Object
Public: Queries the media end point.
-
#initialize(auth_token) ⇒ MediaService
constructor
Public: Creates a new instance.
-
#update_media_items(items, params) ⇒ Object
Public: Updates the supplied items and their properties using the PUT method.
Constructor Details
#initialize(auth_token) ⇒ MediaService
Public: Creates a new instance
auth_token - the authentication token to be used
24 25 26 |
# File 'lib/platform_lib/media_service.rb', line 24 def initialize(auth_token) @auth_token = auth_token end |
Instance Method Details
#get_media_items(params = {}, &block) ⇒ Object
Public: Queries the media end point
params - an optional hash of parameters (query string) block - an optional block to be called for each item returned
Examples:
items = media_service.get_media_items(range: "1-10")
media_service.get_media_items(byCustomValue: "{test}{val}") do |item|
puts item.title
end
Returns the items supplied from the service
42 43 44 45 46 47 48 |
# File 'lib/platform_lib/media_service.rb', line 42 def get_media_items(params = {}, &block) if block.nil? get_entries(END_POINT, params) else get_entries(END_POINT, params, &block) end end |
#update_media_items(items, params) ⇒ Object
Public: Updates the supplied items and their properties using the PUT method
items - an array of items to be updated params - an optional hash of parameters (query string)
Example:
items = [ { id: "id_value", guid: "guid_value" }, .. ]
media_service.update_media_items(items)
61 62 63 |
# File 'lib/platform_lib/media_service.rb', line 61 def update_media_items(items, params) put_entries("#{END_POINT}/list", params, items) end |