Class: ApiBucket::Itunes::Client
- Inherits:
-
Object
- Object
- ApiBucket::Itunes::Client
- Includes:
- Http
- Defined in:
- lib/api_bucket/itunes/client.rb,
lib/api_bucket/itunes/client/http.rb
Defined Under Namespace
Modules: Http
Constant Summary collapse
- REQUEST_URL =
'http://itunes.apple.com/search'
- REQUEST_URL_ITEM =
'http://itunes.apple.com/lookup'
Instance Attribute Summary collapse
-
#country ⇒ Object
Returns the value of attribute country.
-
#limit ⇒ Object
Returns the value of attribute limit.
Instance Method Summary collapse
- #categories ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#lookup(id, params = {}) ⇒ Object
lookup.
- #search(keywords, params = {}) ⇒ Object
Methods included from Base::Client::Http
Constructor Details
Instance Attribute Details
#country ⇒ Object
Returns the value of attribute country.
7 8 9 |
# File 'lib/api_bucket/itunes/client.rb', line 7 def country @country end |
#limit ⇒ Object
Returns the value of attribute limit.
7 8 9 |
# File 'lib/api_bucket/itunes/client.rb', line 7 def limit @limit end |
Instance Method Details
#categories ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/api_bucket/itunes/client.rb', line 12 def categories { all: 'All', movie: 'Movie', podcast: 'Podcast', music: 'Music', musicVideo: 'MusicVideo', audiobook: 'Audiobook', shortFilm: 'ShortFilm', tvShow: 'TvShow', software: 'Software', ebook: 'Ebook', } end |
#lookup(id, params = {}) ⇒ Object
lookup
51 52 53 54 55 56 57 58 59 |
# File 'lib/api_bucket/itunes/client.rb', line 51 def lookup(id, params={}) = { country: self.country, id: id, } .merge!(params) ApiBucket::Itunes::Response.new(send_request(, REQUEST_URL_ITEM)) end |
#search(keywords, params = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/api_bucket/itunes/client.rb', line 33 def search(keywords, params={}) = { limit: self.limit, country: self.country, media: params[:search_index], term: keywords, } .merge!(params) # delete no needed keys .delete(:keywords) .delete(:search_index) [:media] = 'all' if [:media].nil? ApiBucket::Itunes::Response.new(send_request(, REQUEST_URL)) end |