Class: AppStore::Client

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

Overview

Client regroups all the calling and xml parsing mechanism to call the AppStore.

Constant Summary collapse

FeaturedCategoriesURL =

Urls

"http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewFeaturedSoftwareCategories"
ApplicationURL =
"http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware"
CategoryURL =
"http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewGenre"
SearchURL =
"http://ax.search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search"
StoreFronts =

Store Front

{
  :ar   => "143505",  # Argentina
  :au   => "143460",  # Australia
  :be   => "143446",  # Belgium
  :br   => "143503",  # Brazil
  :ca   => "143455",  # Canada
  :cl   => "143483",  # Chile
  :cn   => "143465",  # China
  :fr   => "143442",  # France
  :us   => "143441",  # United states
}
DefaultStoreFrontName =
:us

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Client

Returns a new instance of Client.


35
36
37
38
39
40
41
42
# File 'lib/app_store/client.rb', line 35

def initialize(args = {})
  @store_front_name = args[:store_front] || DefaultStoreFrontName
  # About the X-Apple-Store-Front header: this is used to select which store and which language.
  # Format is XXXXXX-Y,Z where XXXXXX is the store number (us, french, ...), Y the language and Z the return format.
  # If you omit the language, the default one for the store is used.
  # Return format can be either "1" or "2" : "1" returns data to be directly displayed and "2" is a more structured format.
  @store_front = "#{StoreFronts[@store_front_name]},2"
end

Instance Attribute Details

#store_frontObject (readonly)

Returns the value of attribute store_front


11
12
13
# File 'lib/app_store/client.rb', line 11

def store_front
  @store_front
end

#store_front_nameObject (readonly)

Returns the value of attribute store_front_name


12
13
14
# File 'lib/app_store/client.rb', line 12

def store_front_name
  @store_front_name
end

Instance Method Details

#iphone_get(url, params = {}) ⇒ Object Also known as: get

Call the Apple AppStore using given url and passing params with an HTTP Get method. Call is seen as a fake iPhone iTunes client.


46
47
48
# File 'lib/app_store/client.rb', line 46

def iphone_get(url, params = {})
  Plist::parse_xml make_call_and_handle_answer(iphone_agent, url, params).body
end

#itunes_get(url, params = {}) ⇒ Object

Call the Apple AppStore using given url and passing params with HTTP Get method. Call is seen as a fake Mac OS X iTunes client.


54
55
56
# File 'lib/app_store/client.rb', line 54

def itunes_get(url, params = {})
  Nokogiri.parse make_call_and_handle_answer(itunes_agent, url, params).body
end