Class: Shopify

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/shopify.rb

Overview

Class: Shopify Usage:

shop = Shopify.new(host, api_key, password)
shop.orders

Defined Under Namespace

Classes: Article, CustomCollection, ShopifyModel

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, api_key = nil, password = nil) ⇒ Shopify

Returns a new instance of Shopify.



18
19
20
21
22
23
24
# File 'lib/shopify.rb', line 18

def initialize(host, api_key=nil, password=nil)
  host.gsub!(/https?:\/\//, '') # remove http(s)://
  @host = host.include?('.') ? host : "#{host}.myshopify.com" # extend url to myshopify.com if no host is given
  @api_key = api_key
  @password = password
  setup
end

Instance Attribute Details

#base_uriObject

Returns the value of attribute base_uri.



16
17
18
# File 'lib/shopify.rb', line 16

def base_uri
  @base_uri
end

#hostObject (readonly)

Returns the value of attribute host.



13
14
15
# File 'lib/shopify.rb', line 13

def host
  @host
end

Instance Method Details

#needs_authorization?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/shopify.rb', line 26

def needs_authorization?
  ![@host, @api_key, @password].all?
end

#options(opts = {}) ⇒ Object



39
40
41
# File 'lib/shopify.rb', line 39

def options(opts={})
  {:base_uri => @base_uri, :basic_auth => @basic_auth, :format => @format}.merge(opts)
end