Class: FastlaneCore::ItunesSearchApi
- Inherits:
-
Object
- Object
- FastlaneCore::ItunesSearchApi
- Defined in:
- fastlane_core/lib/fastlane_core/itunes_search_api.rb
Overview
A wrapper around the Apple iTunes Search API to access app information like the app identifier of an app.
Class Method Summary collapse
-
.fetch(id, country = nil) ⇒ Hash
Fetch all information you can get from a specific AppleID of an app.
-
.fetch_bundle_identifier(id) ⇒ String
This method only fetches the bundle identifier of a given app.
- .fetch_by_identifier(app_identifier, country = nil) ⇒ Object
- .fetch_url(url) ⇒ Object
Class Method Details
.fetch(id, country = nil) ⇒ Hash
Fetch all information you can get from a specific AppleID of an app
21 22 23 24 25 |
# File 'fastlane_core/lib/fastlane_core/itunes_search_api.rb', line 21 def self.fetch(id, country = nil) # Example: https://itunes.apple.com/lookup?id=284882215[&country=FR] suffix = country.nil? ? nil : "&country=#{country}" fetch_url("https://itunes.apple.com/lookup?id=#{id}#{suffix}") end |
.fetch_bundle_identifier(id) ⇒ String
This method only fetches the bundle identifier of a given app
36 37 38 |
# File 'fastlane_core/lib/fastlane_core/itunes_search_api.rb', line 36 def self.fetch_bundle_identifier(id) self.fetch(id)['bundleId'] end |
.fetch_by_identifier(app_identifier, country = nil) ⇒ Object
27 28 29 30 31 |
# File 'fastlane_core/lib/fastlane_core/itunes_search_api.rb', line 27 def self.fetch_by_identifier(app_identifier, country = nil) # Example: http://itunes.apple.com/lookup?bundleId=net.sunapps.1[&country=FR] suffix = country.nil? ? nil : "&country=#{country}" fetch_url("https://itunes.apple.com/lookup?bundleId=#{app_identifier}#{suffix}") end |
.fetch_url(url) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'fastlane_core/lib/fastlane_core/itunes_search_api.rb', line 40 def self.fetch_url(url) response = JSON.parse(open(url).read) return nil if response['resultCount'] == 0 return response['results'].first rescue UI.error("Could not find object '#{url}' using the iTunes API") nil end |