Class: Establish::ItunesSearchApi

Inherits:
Object
  • Object
show all
Defined in:
lib/establish/itunes_search_api.rb

Class Method Summary collapse

Class Method Details

.fetch(id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/establish/itunes_search_api.rb', line 5

def self.fetch(id)
  # Example: https://itunes.apple.com/lookup?id=284882215

  response = JSON.parse(open("https://itunes.apple.com/lookup?id=#{id}").read)
  return nil if response['resultCount'] == 0

  return response['results'].first
rescue
  Helper.log.error "Could not find object '#{id}' using the iTunes API"
  nil
end

.fetch_bundle_identifier(id) ⇒ Object



17
18
19
# File 'lib/establish/itunes_search_api.rb', line 17

def self.fetch_bundle_identifier(id)
  self.fetch(id)['bundleId']
end