Class: Gracenote::Client
- Inherits:
-
Object
- Object
- Gracenote::Client
- Includes:
- Http, QueryBuilder, Request::Fetch, Request::Register, Request::Search
- Defined in:
- lib/gracenote/client.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#country ⇒ Object
Returns the value of attribute country.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
- #auth ⇒ Object
-
#initialize(client_id:, user_id: nil, lang: nil, country: nil) ⇒ Client
constructor
A new instance of Client.
- #query(cmd, options = {}, &block) ⇒ Object
- #short_client_id ⇒ Object
Methods included from Request::Fetch
Methods included from Request::Search
Methods included from Request::Register
Methods included from QueryBuilder
Methods included from Http
#agent, #host, #log_enabled?, #path, #post
Constructor Details
#initialize(client_id:, user_id: nil, lang: nil, country: nil) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 |
# File 'lib/gracenote/client.rb', line 20 def initialize(client_id:, user_id: nil, lang: nil, country: nil) @client_id = client_id @user_id = user_id @lang = lang || "eng" @country = country || "usa" end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
11 12 13 |
# File 'lib/gracenote/client.rb', line 11 def client_id @client_id end |
#country ⇒ Object
Returns the value of attribute country.
12 13 14 |
# File 'lib/gracenote/client.rb', line 12 def country @country end |
#lang ⇒ Object
Returns the value of attribute lang.
12 13 14 |
# File 'lib/gracenote/client.rb', line 12 def lang @lang end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
11 12 13 |
# File 'lib/gracenote/client.rb', line 11 def user_id @user_id end |
Instance Method Details
#auth ⇒ Object
31 32 33 34 |
# File 'lib/gracenote/client.rb', line 31 def auth raise "user_id is empty" unless user_id { client: client_id, user: user_id } end |
#query(cmd, options = {}, &block) ⇒ Object
36 37 38 39 40 |
# File 'lib/gracenote/client.rb', line 36 def query(cmd, = {}, &block) request = build_query(cmd, , &block).to_xml response = post(request) Response.new(response) end |
#short_client_id ⇒ Object
27 28 29 |
# File 'lib/gracenote/client.rb', line 27 def short_client_id client_id.split("-", 2)[0] end |