Class: Veoh
- Inherits:
-
Object
- Object
- Veoh
- Defined in:
- lib/veoh.rb
Constant Summary collapse
- VERSION =
'0.0.1'
- DEFAULT_HOST =
'http://www.veoh.com'
- DEFAULT_HOST_SSL =
'https://www.veoh.com'
- DEFAULT_API_PATH =
'/rest/v2/execute.xml'
Instance Method Summary collapse
- #call_method(method, opts = {}, verb = 'get', use_ssl = nil) ⇒ Object
- #get_token(opts = {}) ⇒ Object
-
#initialize(opts = {}) ⇒ Veoh
constructor
A new instance of Veoh.
Constructor Details
#initialize(opts = {}) ⇒ Veoh
Returns a new instance of Veoh.
22 23 24 25 26 27 |
# File 'lib/veoh.rb', line 22 def initialize(opts = {}) raise 'API key required' unless opts[:apiKey] @api_key = opts[:apiKey] @secret = opts[:secret] end |
Instance Method Details
#call_method(method, opts = {}, verb = 'get', use_ssl = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/veoh.rb', line 29 def call_method(method, opts = {}, verb = 'get', use_ssl = nil) opts.update(:method => method, :apiKey => @api_key) @host = use_ssl ? DEFAULT_HOST_SSL : DEFAULT_HOST @api_path = DEFAULT_API_PATH case verb when 'get' raw_response = get_request("#{@host}#{@api_path}", opts) when 'post' raw_response = post_request("#{@host}#{@api_path}", opts) end response = XmlSimple.xml_in(raw_response, { 'ForceArray' => nil }) raise response unless response['stat'] == 'ok' response end |
#get_token(opts = {}) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/veoh.rb', line 47 def get_token(opts = {}) raise 'Username and Password required.' unless opts[:username] and opts[:password] response = call_method('veoh.people.authenticate', opts, 'post', true) @token = response['authentication']['token'] end |