Class: Shopify
- Inherits:
-
Object
- Object
- Shopify
- Includes:
- HTTParty
- Defined in:
- lib/shopify.rb,
lib/shopify/support.rb
Overview
Class: Shopify Usage:
shop = Shopify.new(host, [key, [secret, [token]]])
shop.orders
Defined Under Namespace
Classes: Article, CustomCollection, ShopifyModel
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
- #options(opts = {}) ⇒ Object
Constructor Details
#initialize(host, key = nil, secret = nil, token = nil) ⇒ Shopify
Returns a new instance of Shopify.
15 16 17 18 19 20 21 22 |
# File 'lib/shopify.rb', line 15 def initialize(host, key=nil, secret=nil, token=nil) 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
33 34 35 |
# File 'lib/shopify.rb', line 33 def (mode='w') "http://#{@host}/admin/api/auth?api_key=#{@key}&mode=#{mode}" end |
#authorize!(token) ⇒ Object
28 29 30 31 |
# File 'lib/shopify.rb', line 28 def (token) @token = token setup end |
#needs_authorization? ⇒ Boolean
24 25 26 |
# File 'lib/shopify.rb', line 24 def ![@host, @key, @secret, @token].all? end |
#options(opts = {}) ⇒ Object
46 47 48 |
# File 'lib/shopify.rb', line 46 def (opts={}) {:base_uri => @base_uri, :basic_auth => @basic_auth, :format => @format}.merge(opts) end |