Class: ProteusClient::Proxy
- Inherits:
-
Object
- Object
- ProteusClient::Proxy
- Defined in:
- lib/proteus_client/proxy.rb
Overview
Provides an interface for Proteus REST service to encode videos
Instance Method Summary collapse
- #create_recordings ⇒ Object
- #create_version(video_id, version_name, solution) ⇒ Object
- #create_video(url, solution, version_name) ⇒ Object
- #get_recording(id) ⇒ Object
- #get_video(id) ⇒ Object
-
#initialize(options = {}) ⇒ Proxy
constructor
A new instance of Proxy.
Constructor Details
#initialize(options = {}) ⇒ Proxy
Returns a new instance of Proxy.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/proteus_client/proxy.rb', line 17 def initialize( = {}) = { account: ProteusClient.config.account, api_key: ProteusClient.config.api_key, root: ProteusClient.config.root }.merge() raise "AccountNotDefined" unless [:account] raise "APIKeyNotDefined" unless [:api_key] raise "RootNotDefined" unless [:root] @user = [:account] @password = [:api_key] @root = resource([:root]) end |
Instance Method Details
#create_recordings ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/proteus_client/proxy.rb', line 33 def create_recordings recordings = link(@root, 'proteus:recordings') response = resource(recordings).post({}) properties = Representers::Recording.new(response).to_hash ProteusClient::Recording.new(properties) end |
#create_version(video_id, version_name, solution) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/proteus_client/proxy.rb', line 72 def create_version(video_id, version_name, solution) url = link(@root, 'proteus:video') video = (url, 'id', video_id) versions = link(resource(video), 'proteus:video:versions') params = { version_name: version_name, solution: solution } response = resource(versions).post(params) {message: 'success'} end |
#create_video(url, solution, version_name) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/proteus_client/proxy.rb', line 52 def create_video(url, solution, version_name) videos = link(@root, 'proteus:videos') params = { url: url, solution: solution, version_name: version_name } response = resource(videos).post(params) properties = Representers::Video.new(response).to_hash ProteusClient::Video.new(properties) end |
#get_recording(id) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/proteus_client/proxy.rb', line 42 def get_recording(id) url = link(@root, 'proteus:recording') recording = (url, 'id', id) response = resource(recording).get properties = Representers::Recording.new(response).to_hash ProteusClient::Recording.new(properties) end |
#get_video(id) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/proteus_client/proxy.rb', line 62 def get_video(id) url = link(@root, 'proteus:video') video = (url, 'id', id) response = resource(video).get properties = Representers::Video.new(response).to_hash ProteusClient::Video.new(properties) end |