Class: Kin::Client
- Inherits:
-
Object
- Object
- Kin::Client
- Defined in:
- lib/kin.rb
Instance Attribute Summary collapse
-
#apikey ⇒ Object
Returns the value of attribute apikey.
Instance Method Summary collapse
- #active_sales ⇒ Object
- #active_sales_in_store(store_key) ⇒ Object
-
#initialize(apikey) ⇒ Client
constructor
A new instance of Client.
- #product_detail(product_id) ⇒ Object
- #product_detail_from_url(url) ⇒ Object
- #sale_detail(store_key, sale_key) ⇒ Object
- #upcoming_sales ⇒ Object
- #upcoming_sales_in_store(store_key) ⇒ Object
Constructor Details
#initialize(apikey) ⇒ Client
Returns a new instance of Client.
21 22 23 |
# File 'lib/kin.rb', line 21 def initialize(apikey) @apikey = apikey.to_s end |
Instance Attribute Details
#apikey ⇒ Object
Returns the value of attribute apikey.
18 19 20 |
# File 'lib/kin.rb', line 18 def apikey @apikey end |
Instance Method Details
#active_sales ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/kin.rb', line 25 def active_sales sales = make_request(Kin.domain + "sales/active.json")['sales'] sales.each_with_index do |sale, i| sales[i] = Kin::Sale.new(sale) end sales end |
#active_sales_in_store(store_key) ⇒ Object
33 34 35 36 |
# File 'lib/kin.rb', line 33 def active_sales_in_store(store_key) raise "Invalid Store Key" unless validate_store_key(store_key) make_request(Kin.domain + "sales/" + store_key + "/active.json") end |
#product_detail(product_id) ⇒ Object
52 53 54 |
# File 'lib/kin.rb', line 52 def product_detail(product_id) make_request(Kin.domain + "products/" + product_id.to_s + "/detail.json") end |
#product_detail_from_url(url) ⇒ Object
56 57 58 59 |
# File 'lib/kin.rb', line 56 def product_detail_from_url(url) raise 'Invalid URL' unless validate_url(url) make_request(url) end |
#sale_detail(store_key, sale_key) ⇒ Object
47 48 49 50 |
# File 'lib/kin.rb', line 47 def sale_detail(store_key, sale_key) raise "Invalid Store Key" unless validate_store_key(store_key) make_request(Kin.domain + "sales/" + store_key + "/" + sale_key + "/detail.json") end |