class Obecon::Client
Constants
- DEFAULT_OPTIONS
- MOVIE_PARAM_NAME
- USER_AGENT
Attributes
options[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/obecon/client.rb, line 17 def initialize(options = {}) store_options(options) raise ArgumentError, "A token must be present" if token.nil? end
Public Instance Methods
host()
click to toggle source
accessors for options
# File lib/obecon/client.rb, line 30 def host @options[:host] end
movie(movie_id)
click to toggle source
# File lib/obecon/client.rb, line 22 def movie(movie_id) handle_response do self.class.get(build_query(movie_id)).body end end
path()
click to toggle source
# File lib/obecon/client.rb, line 34 def path @options[:path] end
token()
click to toggle source
# File lib/obecon/client.rb, line 38 def token @options[:token] end
Private Instance Methods
build_query(movie_id)
click to toggle source
# File lib/obecon/client.rb, line 54 def build_query(movie_id) URI::HTTP.build( host: host, path: path, query: URI.encode_www_form( token: token, mode: "event", rceid: "0", id: movie_id, ), ).to_s end
handle_response() { || ... }
click to toggle source
# File lib/obecon/client.rb, line 44 def handle_response response = yield ResponseWrapper.new(response) end
store_options(options = {})
click to toggle source
# File lib/obecon/client.rb, line 49 def store_options(options = {}) @options ||= DEFAULT_OPTIONS.dup @options.merge!(options) end