Class: AppStoreLookup::App

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ App

Returns a new instance of App.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/app_store_lookup.rb', line 8

def initialize(attributes = {})
	require 'date'
	@id = attributes['trackId'].to_i
	@name = attributes['trackName']	  		
	@censored_name = attributes['trackCensoredName']
	@kind = attributes['kind']
	@release_date = DateTime.parse(attributes['releaseDate'])
	@primary_genre = AppStoreLookup::AppGenre.new(:name => attributes['primaryGenreName'], :id => attributes['primaryGenreId'])
	@genres = attributes['genres'].each_with_index.map {|genre,i| AppStoreLookup::AppGenre.new(:name => genre, :id => attributes['genreIds'][i])}
	@price = attributes['price'].to_f
	@currency = attributes['currency']
	@version = attributes['version']
	@current_version_release_date = DateTime.parse(attributes['currentVersionReleaseDate'])
	@artist = AppStoreLookup::AppArtist.new(:name => attributes['artistName'], :id => attributes['artistId'], :url => attributes['artistViewUrl'])
	@bundle_id = attributes['bundleId']
	@minimum_os_version = attributes['minimum_os_version']
	@description = attributes['description']
	@is_vpp_device_based_licensing_enabled = attributes['isVppDeviceBasedLicensingEnabled']
	@is_game_center_enabled = attributes['is_game_center_enabled']
	@rating = AppStoreLookup::AppRating.new(:count => attributes['userRatingCount'], :rating => attributes['averageUserRating'])
	@current_version_rating = AppStoreLookup::AppRating.new(:count => attributes['userRatingCountForCurrentVersion'], :rating => attributes['averageUserRatingForCurrentVersion'])
	@seller = AppStoreLookup::AppSeller.new(:name => attributes['sellerName'], :url => attributes['sellerUrl'])
	@file_size = attributes['fileSizeBytes'].to_i
	@languages = attributes['languageCodesISO2A'].map {|l| AppStoreLookup::AppLanguage.new(:code => l)}
	@content_advisory_rating = attributes['contentAdvisoryRating']
	@url = attributes['trackViewUrl']
	@supported_devices = attributes['supportedDevices'].map {|sd| AppStoreLookup::AppSupportedDevices.new(:name => sd)}
	@artwork = { :a60 => AppStoreLookup::AppImage.new(:url => attributes['artworkUrl60']), :a100 => AppStoreLookup::AppImage.new(:url => attributes['artworkUrl100']), :a512 => AppStoreLookup::AppImage.new(:url => attributes['artworkUrl512'])}
	@screenshots = {:iphone => attributes['screenshotUrls'].map {|s| AppStoreLookup::AppImage.new(:url => s)}, :ipad => attributes['ipadScreenshotUrls'].map {|s| AppStoreLookup::AppImage.new(:url => s)}, :apple_tv => attributes['appletvScreenshotUrls'].map {|s| AppStoreLookup::AppImage.new(:url => s)}}
end

Instance Attribute Details

#artistObject (readonly)

Returns the value of attribute artist.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def artist
  @artist
end

#artworkObject (readonly)

Returns the value of attribute artwork.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def artwork
  @artwork
end

#bundle_idObject (readonly)

Returns the value of attribute bundle_id.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def bundle_id
  @bundle_id
end

#censored_nameObject (readonly)

Returns the value of attribute censored_name.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def censored_name
  @censored_name
end

#content_advisory_ratingObject (readonly)

Returns the value of attribute content_advisory_rating.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def content_advisory_rating
  @content_advisory_rating
end

#currencyObject (readonly)

Returns the value of attribute currency.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def currency
  @currency
end

#current_version_ratingObject (readonly)

Returns the value of attribute current_version_rating.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def current_version_rating
  @current_version_rating
end

#current_version_release_dateObject (readonly)

Returns the value of attribute current_version_release_date.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def current_version_release_date
  @current_version_release_date
end

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def description
  @description
end

#file_sizeObject (readonly)

Returns the value of attribute file_size.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def file_size
  @file_size
end

#genresObject (readonly)

Returns the value of attribute genres.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def genres
  @genres
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def id
  @id
end

#is_game_center_enabledObject (readonly)

Returns the value of attribute is_game_center_enabled.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def is_game_center_enabled
  @is_game_center_enabled
end

#is_vpp_device_based_licensing_enabledObject (readonly)

Returns the value of attribute is_vpp_device_based_licensing_enabled.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def is_vpp_device_based_licensing_enabled
  @is_vpp_device_based_licensing_enabled
end

#kindObject (readonly)

Returns the value of attribute kind.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def kind
  @kind
end

#languagesObject (readonly)

Returns the value of attribute languages.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def languages
  @languages
end

#minimum_os_versionObject (readonly)

Returns the value of attribute minimum_os_version.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def minimum_os_version
  @minimum_os_version
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def name
  @name
end

#priceObject (readonly)

Returns the value of attribute price.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def price
  @price
end

#primary_genreObject (readonly)

Returns the value of attribute primary_genre.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def primary_genre
  @primary_genre
end

#ratingObject (readonly)

Returns the value of attribute rating.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def rating
  @rating
end

#release_dateObject (readonly)

Returns the value of attribute release_date.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def release_date
  @release_date
end

#screenshotsObject (readonly)

Returns the value of attribute screenshots.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def screenshots
  @screenshots
end

#sellerObject (readonly)

Returns the value of attribute seller.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def seller
  @seller
end

#supported_devicesObject (readonly)

Returns the value of attribute supported_devices.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def supported_devices
  @supported_devices
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def url
  @url
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/app_store_lookup.rb', line 5

def version
  @version
end

Class Method Details

.find_by_bundle_id(bundle_id) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/app_store_lookup.rb', line 39

def self.find_by_bundle_id(bundle_id)
	require 'net/http'
			require 'uri'
			require 'json'
			listing = JSON.parse(Net::HTTP.get(URI.parse("https://itunes.apple.com/lookup?bundleId="+bundle_id)))['results']
			unless listing.empty?
		AppStoreLookup::App.new(listing[0])
	else

	end 
end