Class: FastSpring::LocalizedStorePricing

Inherits:
PublicApiBase show all
Defined in:
lib/fastspring-saasy/localized_store_pricing.rb

Instance Method Summary collapse

Methods inherited from PublicApiBase

find, #initialize

Constructor Details

This class inherits a constructor from FastSpring::PublicApiBase

Instance Method Details

#base_localized_store_pricing_pathObject



11
12
13
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 11

def base_localized_store_pricing_path
  "/#{@company}/api/price"
end

#findObject

Get the localized store pricing from Saasy



4
5
6
7
8
9
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 4

def find
  # For some reason the implicit determination of the Txt parser does not work.
  # So we'll just blatently pass it in right now.
  @response = self.class.get(base_localized_store_pricing_path, :query => query, :parser => Parser::Txt)
  self
end

#product_quantity(product_path) ⇒ Object



37
38
39
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 37

def product_quantity(product_path)
  parsed_response[product_path]["quantity"]
end

#product_unit_currency(product_path) ⇒ Object



45
46
47
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 45

def product_unit_currency(product_path)
  parsed_response[product_path]["unit_currency"]
end

#product_unit_display(product_path) ⇒ Object



49
50
51
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 49

def product_unit_display(product_path)
  parsed_response[product_path]["unit_display"]
end

#product_unit_html(product_path) ⇒ Object



53
54
55
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 53

def product_unit_html(product_path)
  parsed_response[product_path]["unit_html"]
end

#product_unit_value(product_path) ⇒ Object



41
42
43
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 41

def product_unit_value(product_path)
  parsed_response[product_path]["unit_value"]
end

#queryObject



15
16
17
18
19
20
21
22
23
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 15

def query
  query_hash = Hash.new
  @product_paths.each_index{ |index| query_hash["product_#{(index + 1)}_path".to_sym] = @product_paths[index] }
  query_hash.merge({ 
    :user_remote_addr => @remote_ip,
    :user_accept_language => @http_accept_language,
    :user_x_forwarded_for => @http_x_forwarded_for
  })
end

#user_countryObject



25
26
27
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 25

def user_country
  parsed_response['user_country']
end

#user_currencyObject



33
34
35
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 33

def user_currency
  parsed_response['user_currency']
end

#user_languageObject



29
30
31
# File 'lib/fastspring-saasy/localized_store_pricing.rb', line 29

def user_language
  parsed_response['user_language']
end