Class: Shopify
Overview
Class: Shopify Usage:
shop = Shopify.new(host, [key, [secret, [token]]])
shop.orders
TODO: Make the object remember the results of queries such as shop.orders when called without parameters,
and reload only when you call shop.orders(true)
Defined Under Namespace
Classes: Article, Blog, Collect, Comment, Country, CustomCollection, Fulfillment, Image, LineItem, Order, Page, Product, Province, Redirect, Shop, ShopifyModel, Transaction, Variant
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #authorization_url(mode = 'w') ⇒ Object
- #authorize!(token) ⇒ Object
-
#initialize(host, key = nil, secret = nil, token = nil) ⇒ Shopify
constructor
A new instance of Shopify.
- #needs_authorization? ⇒ Boolean
Constructor Details
#initialize(host, key = nil, secret = nil, token = nil) ⇒ Shopify
Returns a new instance of Shopify.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/shopify.rb', line 14 def initialize(host, key=nil, secret=nil, token=nil) @default_options = {} extend HTTParty::ClassMethods host.gsub!(/https?:\/\//, '') # remove http(s):// @host = host.include?('.') ? host : "#{host}.myshopify.com" # extend url to myshopify.com if no host is given @key = key @secret = secret @token = token setup end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
12 13 14 |
# File 'lib/shopify.rb', line 12 def host @host end |
Instance Method Details
#authorization_url(mode = 'w') ⇒ Object
35 36 37 |
# File 'lib/shopify.rb', line 35 def (mode='w') "http://#{@host}/admin/api/auth?api_key=#{@key}&mode=#{mode}" end |
#authorize!(token) ⇒ Object
30 31 32 33 |
# File 'lib/shopify.rb', line 30 def (token) @token = token setup end |
#needs_authorization? ⇒ Boolean
26 27 28 |
# File 'lib/shopify.rb', line 26 def ![@host, @key, @secret, @token].all? end |