Class: Nashville::Client
- Inherits:
-
Object
- Object
- Nashville::Client
- Defined in:
- lib/nashville/client.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
Returns the value of attribute country.
-
#search_url ⇒ Object
Returns the value of attribute search_url.
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #lookup(params = {}) ⇒ Object
- #search(params = {}) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
12 13 14 15 |
# File 'lib/nashville/client.rb', line 12 def initialize @search_url = ENV['ITUNES_SEARCH_ENDPOINT'] || ITUNES_SEARCH_ENDPOINT @country = 'US' end |
Instance Attribute Details
#country ⇒ Object
Returns the value of attribute country.
10 11 12 |
# File 'lib/nashville/client.rb', line 10 def country @country end |
#search_url ⇒ Object
Returns the value of attribute search_url.
9 10 11 |
# File 'lib/nashville/client.rb', line 9 def search_url @search_url end |
Instance Method Details
#lookup(params = {}) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/nashville/client.rb', line 26 def lookup(params = {}) uri = URI.join(@search_url, "lookup") uri.query = URI.encode_www_form(params) json_response_from_uri(uri)["results"] end |
#search(params = {}) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/nashville/client.rb', line 17 def search(params = {}) params[:country] ||= @country uri = URI.join(@search_url, "search") uri.query = URI.encode_www_form(params) json_response_from_uri(uri)["results"] end |