dcparker-shopify 0.1.0 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1 +1,2 @@
1
1
  v0.1.0 First release, a rewrite of Shopify's own Rails plugin, turned into a gem with similar workings.
2
+ v0.1.9 2.0 Beta, another rewrite using the light HTTParty instead of ActiveResource.
data/Manifest CHANGED
@@ -1,11 +1,5 @@
1
1
  CHANGELOG
2
- lib/shopify/address.rb
3
- lib/shopify/order.rb
4
- lib/shopify/product.rb
5
- lib/shopify/sale.rb
6
- lib/shopify/session.rb
7
- lib/shopify/shop.rb
8
- lib/shopify/site.rb
2
+ lib/shopify/support.rb
9
3
  lib/shopify.rb
10
4
  LICENSE
11
5
  Manifest
data/lib/shopify.rb CHANGED
@@ -1,93 +1,149 @@
1
+ include_path = File.expand_path(File.dirname(__FILE__))
2
+ $:.unshift(include_path) unless $:.include?(include_path)
3
+ require 'shopify/support'
4
+
1
5
  module Shopify
2
- autoload :Session, 'shopify/session'
3
- autoload :Shop, 'shopify/shop'
4
- autoload :Product, 'shopify/product'
5
- autoload :Variant, 'shopify/product'
6
- autoload :Image, 'shopify/product'
7
- autoload :Order, 'shopify/order'
8
- autoload :LineItem, 'shopify/order'
9
- autoload :ShippingLine, 'shopify/order'
10
- autoload :CustomCollection, 'shopify/order'
11
- autoload :ShippingAddress, 'shopify/address'
12
- autoload :BillingAddress, 'shopify/address'
13
- autoload :Country, 'shopify/address'
14
- autoload :Province, 'shopify/address'
15
- autoload :Sale, 'shopify/sale'
16
- autoload :Authorization, 'shopify/sale'
17
- autoload :Payment, 'shopify/sale'
18
- autoload :Page, 'shopify/site'
19
- autoload :Blog, 'shopify/site'
20
- autoload :Article, 'shopify/site'
21
-
22
- class << self
23
- attr_reader :key, :secret
24
-
25
- # Lists the session stack.
26
- def sessions
27
- @sessions ||= []
6
+ include HTTParty
7
+
8
+ def self.setup(host, key=nil, secret=nil, token=nil)
9
+ host.gsub!(/https?:\/\//, '') # remove http(s)://
10
+ @host = host.include?('.') ? host : "#{host}.myshopify.com" # extend url to myshopify.com if no host is given
11
+ @key = key
12
+ @secret = secret
13
+ @token = token
14
+ if [host, key, secret, token].all?
15
+ base_uri "http://#{@host}/admin"
16
+ basic_auth @key, Digest::MD5.hexdigest("#{@secret.chomp}#{@token.chomp}")
17
+ format :xml
18
+ return false
19
+ else
20
+ "http://#{@host}/admin/api/auth?api_key=#{@key}&mode=#{mode}"
28
21
  end
22
+ end
29
23
 
30
- # Returns the last session on the sessions stack.
31
- def current_session
32
- sessions.last
24
+ # /admin/blogs.xml
25
+ class Blog < ShopifyModel
26
+ top_level
27
+ attr_accessor :commentable, :feedburner, :feedburner_locations, :handle, :id, :shop_id, :title, :updated_at
28
+
29
+ # Get all articles in this blog.
30
+ def articles
33
31
  end
32
+ end
34
33
 
35
- # Sets the current_session / appends a session to the sessions stack.
36
- def current_session=(session)
37
- sessions << session
34
+ # /admin/blogs/[blog_id]/articles.xml
35
+ class Article < ShopifyModel
36
+ child_of Blog
37
+ attr_accessor :author, :blog_id, :body, :body_html, :created_at, :id, :published_at, :title, :updated_at
38
+ def comments(query_params={})
39
+ Shopify.comments(query_params.merge(:article_id => id, :blog_id => blog_id))
38
40
  end
41
+ end
42
+
43
+ # /admin/comments.xml?article_id=*&blog_id=*
44
+ class Comment < ShopifyModel
45
+ top_level
46
+ attr_accessor :article_id, :author, :blog_id, :body, :body_html, :created_at, :email, :id, :ip, :published_at, :shop_id, :status, :updated_at, :user_agent
47
+ end
48
+
49
+ # /admin/collects.xml
50
+ class Collect < ShopifyModel
51
+ top_level
52
+ attr_accessor :collection_id, :featured, :id, :position, :product_id
53
+ end
39
54
 
40
- # Injects the generated site (with basic auth params) into the ActiveResource::Base subclasses.
41
- def apply_current_session!
42
- current_session.apply!
55
+ # /admin/countries.xml
56
+ class Country < ShopifyModel
57
+ top_level
58
+ attr_accessor :code, :id, :name, :tax
59
+
60
+ # Get all province divisions within this country.
61
+ def provinces
43
62
  end
63
+ end
44
64
 
45
- # Perform a block within a specific session, and reset the current session to the previous after execution.
46
- def with_session(session,&block)
47
- sessions << session
48
- apply_current_session!
49
- result = yield
50
- sessions.pop
51
- apply_current_session!
52
- return result
65
+ # /admin/custom_collections.xml
66
+ class CustomCollection < ShopifyModel
67
+ top_level
68
+ attr_accessor :body, :body_html, :handle, :id, :published_at, :sort_order, :title, :updated_at
69
+ def products(query_params={})
70
+ Shopify.products(query_params.merge(:collection_id => id))
53
71
  end
54
72
  end
55
- end
56
73
 
57
- # To fix a silly bug in ActiveResource loading... :(
58
- module Enumerable # :nodoc: all
59
- def group_by
74
+ # /admin/orders.xml
75
+ class Order < ShopifyModel
76
+ top_level
77
+ attr_accessor :buyer_accepts_marketing, :closed_at, :created_at, :currency, :email, :financial_status, :fulfillment_status, :gateway, :id, :name, :note, :number, :subtotal_price, :taxes_included, :token, :total_discounts, :total_line_items_price, :total_price, :total_tax, :total_weight, :updated_at, :browser_ip, :billing_address, :shipping_address, :line_items, :shipping_line
78
+
79
+ # Get all fulfillments related to this order.
80
+ def fulfillments
81
+ end
82
+
83
+ # Get all transactions related to this order.
84
+ def transactions
85
+ end
86
+ end
87
+
88
+ # /admin/orders/[order_id]/fulfillments.xml
89
+ class Fulfillment < ShopifyModel
90
+ child_of Order
91
+ attr_accessor :id, :order_id, :status, :tracking_number, :line_items, :receipt
92
+ end
93
+
94
+ # /admin/pages.xml
95
+ class Page < ShopifyModel
96
+ top_level
97
+ attr_accessor :author, :body, :body_html, :created_at, :handle, :ip, :published_at, :shop_id, :title, :updated_at
60
98
  end
61
- end
62
99
 
63
- # Load ActiveResource
64
- gem 'activeresource', '>= 2.1.0'
65
- require 'active_resource'
66
- module ActiveResource # :nodoc: all
67
- class Base
68
- class << self
69
- def site
70
- # Not using superclass_delegating_reader because don't want subclasses to modify superclass instance
71
- #
72
- # With superclass_delegating_reader
73
- #
74
- # Parent.site = 'http://anonymous@test.com'
75
- # Subclass.site # => 'http://anonymous@test.com'
76
- # Subclass.site.user = 'david'
77
- # Parent.site # => 'http://david@test.com'
78
- #
79
- # Without superclass_delegating_reader (expected behaviour)
80
- #
81
- # Parent.site = 'http://anonymous@test.com'
82
- # Subclass.site # => 'http://anonymous@test.com'
83
- # Subclass.site.user = 'david' # => TypeError: can't modify frozen object
84
- #
85
- if defined?(@site)
86
- @site
87
- elsif superclass != Object && superclass.site
88
- superclass.site.dup.freeze
89
- end
90
- end
100
+ # /admin/products.xml?collection_id=*
101
+ class Product < ShopifyModel
102
+ top_level
103
+ attr_accessor :body, :body_html, :created_at, :handle, :id, :product_type, :published_at, :title, :updated_at, :vendor, :tags, :variants, :images
104
+
105
+ # Get all images for this product.
106
+ def images
91
107
  end
108
+
109
+ # Get all variants of this product.
110
+ def variant
111
+ end
112
+ end
113
+
114
+ # /admin/products/[product_id]/images.xml
115
+ class Image < ShopifyModel
116
+ child_of Product
117
+ attr_accessor :id, :position, :product_id, :src
118
+ end
119
+
120
+ # /admin/products/[product_id]/variants.xml
121
+ class Variant < ShopifyModel
122
+ child_of Product
123
+ attr_accessor :compare_at_price, :fulfillment_service, :grams, :id, :inventory_management, :inventory_policy, :inventory_quantity, :position, :price, :product_id, :sku, :title
124
+ end
125
+
126
+ # /admin/countries/[country_id]/provinces.xml
127
+ class Province < ShopifyModel
128
+ child_of Country
129
+ attr_accessor :code, :id, :name, :tax
130
+ end
131
+
132
+ # /admin/redirects.xml
133
+ class Redirect < ShopifyModel
134
+ top_level
135
+ attr_accessor :id, :path, :shop_id, :target
136
+ end
137
+
138
+ # /admin/shop.xml
139
+ class Shop < ShopifyModel
140
+ top_level :singular
141
+ attr_accessor :active_subscription_id, :address1, :city, :country, :created_at, :domain, :email, :id, :name, :phone, :province, :public, :source, :zip, :taxes_included, :currency, :timezone, :shop_owner
142
+ end
143
+
144
+ # /admin/orders/[order_id]/transactions.xml
145
+ class Transaction < ShopifyModel
146
+ child_of Order
147
+ attr_accessor :amount, :authorization, :created_at, :kind, :order_id, :status, :receipt
92
148
  end
93
149
  end
@@ -0,0 +1,104 @@
1
+ require 'rubygems'
2
+ require 'extlib'
3
+ gem 'jnunemaker-httparty', '>=0.3.1'
4
+ require 'httparty'
5
+ require 'bigdecimal'
6
+ require 'digest/md5'
7
+
8
+ module Shopify
9
+ def self.get(*args)
10
+ puts "getting #{args.map {|i| i.inspect}.join(', ')}"
11
+ super
12
+ end
13
+
14
+ def self.def_collections(*klasses)
15
+ klasses.each do |klass|
16
+ kn = klass.name.gsub(/.*::/,'')
17
+ class_eval "
18
+ def self.#{kn.snake_case.pluralize}(query_params={})
19
+ json = get(\"#{klass.site_prefix}/#{kn.snake_case.pluralize}.xml\", :query => query_params)
20
+ if json['#{kn.snake_case.pluralize}']
21
+ json['#{kn.snake_case.pluralize}'].collect {|i| #{kn}.instantiate(i)}
22
+ else
23
+ json
24
+ end
25
+ end
26
+ def self.#{kn.snake_case}(id)
27
+ get(\"/#{kn.snake_case.pluralize}/\#{id}.xml\")
28
+ end
29
+ "
30
+ end
31
+ end
32
+
33
+ class ShopifyModel
34
+ class << self
35
+ def top_level(*options)
36
+ klass_name = self.name.gsub(/.*::/,'')
37
+ if options.include?(:singular)
38
+ # Define singular accessor in Shopify
39
+ eval "
40
+ def Shopify.#{klass_name.snake_case}(query_params={})
41
+ json = Shopify.get(\"/#{klass_name.snake_case}.xml\", :query => query_params)
42
+ begin
43
+ #{klass_name}.instantiate json['#{klass_name.snake_case}']
44
+ rescue => e
45
+ warn \"Error: \#{e.inspect}\"
46
+ json
47
+ end
48
+ end
49
+ "
50
+ else
51
+ # Define plural accessor in Shopify
52
+ eval "
53
+ def Shopify.#{klass_name.snake_case.pluralize}(query_params={})
54
+ json = Shopify.get(\"/#{klass_name.snake_case.pluralize}.xml\", :query => query_params)
55
+ if json['#{klass_name.snake_case.pluralize}']
56
+ json['#{klass_name.snake_case.pluralize}'].collect {|i| #{klass_name}.instantiate(i)}
57
+ else
58
+ json
59
+ end
60
+ end
61
+ def Shopify.#{klass_name.snake_case}(id)
62
+ json = Shopify.get(\"/#{klass_name.snake_case.pluralize}/\#{id}.xml\")
63
+ if json['#{klass_name.snake_case}']
64
+ #{klass_name}.instantiate json['#{klass_name.snake_case}']
65
+ else
66
+ json
67
+ end
68
+ end
69
+ "
70
+ end
71
+ end
72
+ def child_of(parent_klass)
73
+ @parent = parent_klass
74
+ parent_klass_name = parent_klass.name.gsub(/.*::/,'')
75
+ klass_name = self.name.gsub(/.*::/,'')
76
+ parent_klass.class_eval "
77
+ def #{klass_name.snake_case.pluralize}(query_params={})
78
+ @#{klass_name.snake_case.pluralize} ||= begin
79
+ json = Shopify.get(\"/#{parent_klass_name.snake_case.pluralize}/\#{id}/#{klass_name.snake_case.pluralize}.xml\", :query => query_params)
80
+ if json['#{parent_klass_name.snake_case}_#{klass_name.snake_case.pluralize}']
81
+ json['#{parent_klass_name.snake_case}_#{klass_name.snake_case.pluralize}'].collect {|i| #{klass_name}.instantiate(i)}
82
+ else
83
+ json
84
+ end
85
+ end
86
+ @#{klass_name.snake_case.pluralize} = unless @#{klass_name.snake_case.pluralize}.is_a?(#{klass_name})
87
+ @#{klass_name.snake_case.pluralize}
88
+ end
89
+ "
90
+ end
91
+ def is_child?
92
+ (@parent ||= nil)
93
+ end
94
+ end
95
+
96
+ def self.instantiate(attrs={})
97
+ new(attrs.merge('new_record' => false))
98
+ end
99
+ def initialize(attrs={})
100
+ @new_record = true
101
+ attrs.each { |k,v| instance_variable_set("@#{k}", v) }
102
+ end
103
+ end
104
+ end
data/shopify.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{shopify}
5
- s.version = "0.1.0"
5
+ s.version = "0.1.9"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Daniel Parker"]
9
- s.date = %q{2008-12-10}
9
+ s.date = %q{2009-03-10}
10
10
  s.description = %q{Easily communicate with Shopify.com's restful API.}
11
11
  s.email = %q{gems@behindlogic.com}
12
- s.extra_rdoc_files = ["CHANGELOG", "lib/shopify/address.rb", "lib/shopify/order.rb", "lib/shopify/product.rb", "lib/shopify/sale.rb", "lib/shopify/session.rb", "lib/shopify/shop.rb", "lib/shopify/site.rb", "lib/shopify.rb", "LICENSE", "README"]
13
- s.files = ["CHANGELOG", "lib/shopify/address.rb", "lib/shopify/order.rb", "lib/shopify/product.rb", "lib/shopify/sale.rb", "lib/shopify/session.rb", "lib/shopify/shop.rb", "lib/shopify/site.rb", "lib/shopify.rb", "LICENSE", "Manifest", "README", "shopify.gemspec"]
12
+ s.extra_rdoc_files = ["CHANGELOG", "lib/shopify/support.rb", "lib/shopify.rb", "LICENSE", "README"]
13
+ s.files = ["CHANGELOG", "lib/shopify/support.rb", "lib/shopify.rb", "LICENSE", "Manifest", "README", "shopify.gemspec"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://github.com/dcparker/shopify/tree}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Shopify", "--main", "README"]
@@ -24,14 +24,11 @@ Gem::Specification.new do |s|
24
24
  s.specification_version = 2
25
25
 
26
26
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
- s.add_runtime_dependency(%q<activeresource>, [">= 0", "= 2.1.0"])
28
27
  s.add_development_dependency(%q<echoe>, [">= 0"])
29
28
  else
30
- s.add_dependency(%q<activeresource>, [">= 0", "= 2.1.0"])
31
29
  s.add_dependency(%q<echoe>, [">= 0"])
32
30
  end
33
31
  else
34
- s.add_dependency(%q<activeresource>, [">= 0", "= 2.1.0"])
35
32
  s.add_dependency(%q<echoe>, [">= 0"])
36
33
  end
37
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dcparker-shopify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Parker
@@ -9,23 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-10 00:00:00 -08:00
12
+ date: 2009-03-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: activeresource
17
- version_requirement:
18
- version_requirements: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
23
- - - "="
24
- - !ruby/object:Gem::Version
25
- version: 2.1.0
26
- version:
27
15
  - !ruby/object:Gem::Dependency
28
16
  name: echoe
17
+ type: :development
29
18
  version_requirement:
30
19
  version_requirements: !ruby/object:Gem::Requirement
31
20
  requirements:
@@ -41,25 +30,13 @@ extensions: []
41
30
 
42
31
  extra_rdoc_files:
43
32
  - CHANGELOG
44
- - lib/shopify/address.rb
45
- - lib/shopify/order.rb
46
- - lib/shopify/product.rb
47
- - lib/shopify/sale.rb
48
- - lib/shopify/session.rb
49
- - lib/shopify/shop.rb
50
- - lib/shopify/site.rb
33
+ - lib/shopify/support.rb
51
34
  - lib/shopify.rb
52
35
  - LICENSE
53
36
  - README
54
37
  files:
55
38
  - CHANGELOG
56
- - lib/shopify/address.rb
57
- - lib/shopify/order.rb
58
- - lib/shopify/product.rb
59
- - lib/shopify/sale.rb
60
- - lib/shopify/session.rb
61
- - lib/shopify/shop.rb
62
- - lib/shopify/site.rb
39
+ - lib/shopify/support.rb
63
40
  - lib/shopify.rb
64
41
  - LICENSE
65
42
  - Manifest
@@ -1,17 +0,0 @@
1
- module Shopify
2
- class ShippingAddress < ActiveResource::Base
3
- end
4
-
5
- class BillingAddress < ActiveResource::Base
6
- def name
7
- "#{first_name} #{last_name}"
8
- end
9
- end
10
-
11
- class Country < ActiveResource::Base
12
- end
13
-
14
- class Province < ActiveResource::Base
15
- self.prefix = "/admin/countries/:country_id/"
16
- end
17
- end
data/lib/shopify/order.rb DELETED
@@ -1,36 +0,0 @@
1
- module Shopify
2
- class Order < ActiveResource::Base
3
- def fulfilled?
4
- !!fulfillment_status
5
- end
6
-
7
- def closed?
8
- closed_at < Time.now
9
- end
10
-
11
- def close
12
- load_attributes_from_response(post(:close))
13
- end
14
-
15
- def open
16
- load_attributes_from_response(post(:open))
17
- end
18
-
19
- def payments
20
- Payment.get
21
- end
22
-
23
- def capture(amount=nil)
24
- load_attributes_from_response(post(:capture, :amount => amount))
25
- end
26
- end
27
-
28
- class LineItem < ActiveResource::Base
29
- end
30
-
31
- class ShippingLine < ActiveResource::Base
32
- end
33
-
34
- class CustomCollection < ActiveResource::Base
35
- end
36
- end
@@ -1,45 +0,0 @@
1
- module Shopify
2
- class Product < ActiveResource::Base
3
- class << self
4
- # Share all items of this store with the shopify marketplace
5
- def share_all
6
- post :share
7
- end
8
- # Stop sharing all items of this store with the shopify marketplace
9
- def unshare_all
10
- delete :share
11
- end
12
- end
13
-
14
- # Auto-compute the price range
15
- def price_range
16
- prices = variants.collect(&:price)
17
- format = "%0.2f"
18
- if prices.min != prices.max
19
- "#{format % prices.min} - #{format % prices.max}"
20
- else
21
- format % prices.min
22
- end
23
- end
24
- end
25
-
26
- class Variant < ActiveResource::Base
27
- self.prefix = "/admin/products/:product_id/"
28
- end
29
-
30
- class Image < ActiveResource::Base
31
- self.prefix = "/admin/products/:product_id/"
32
-
33
- # generate a method for each possible image variant
34
- [:pico, :icon, :thumb, :small, :medium, :large, :original].each do |m|
35
- reg_exp_match = "/\\1_#{m}.\\2"
36
- define_method(m) { src.gsub(/\/(.*)\.(\w{2,4})/, reg_exp_match) }
37
- end
38
-
39
- # Attach an image to a product.
40
- def attach_image(data, filename = nil)
41
- attributes[:attachment] = Base64.encode64(data)
42
- attributes[:filename] = filename unless filename.nil?
43
- end
44
- end
45
- end
data/lib/shopify/sale.rb DELETED
@@ -1,11 +0,0 @@
1
- module Shopify
2
- class Sale < Payment
3
- end
4
-
5
- class Authorization < Payment
6
- end
7
-
8
- class Payment < ActiveResource::Base
9
- self.prefix = "/admin/orders/:order_id/"
10
- end
11
- end
@@ -1,83 +0,0 @@
1
- require 'digest/md5'
2
-
3
- module Shopify
4
- # Shopify Session
5
- #
6
- # Example:
7
- # class LoginController < ApplicationController
8
- # layout 'empty'
9
- #
10
- # before { Shopify.sessions << Shopify::Session.new(session[:store_name] || params[:store_name], session[:shopify_token], SHOPIFY_APP_SECRET) if Shopify.sessions.empty? && (session[:store_name] || params[:store_name]) }
11
- #
12
- # def signin
13
- # # ask user for his myshopify.com address.
14
- # end
15
- #
16
- # # POST to this with the store name
17
- # def login
18
- # # Set the store_name into the session for future requests.
19
- # session[:store_name] = params[:store_name]
20
- # # This will redirect the user to their Shopify store to authorize your application.
21
- # # Shopify will redirect the user back to your :finalize action when finished.
22
- # redirect Shopify.current_session.permission_url
23
- # end
24
- #
25
- # def finalize
26
- # Shopify.current_session.token = params[:t]
27
- # Shopify.apply_current_session!
28
- # if Shopify.current_session.signed_in?
29
- # redirect # logged in area
30
- # else
31
- # flash[:notice] = "Couldn't sign in to your shopify store."
32
- # redirect url(:signin)
33
- # end
34
- # end
35
- # end
36
- #
37
- class Session
38
- cattr_accessor :protocol
39
- self.protocol = 'http'
40
-
41
- attr_accessor :host, :key, :secret, :token
42
-
43
- def initialize(host, key=nil, secret=nil, token=nil)
44
- host.gsub!(/https?:\/\//, '') # remove http://
45
- host = "#{host}.myshopify.com" unless host.include?('.') # extend url to myshopify.com if no host is given
46
-
47
- self.host = host
48
- self.key = key
49
- self.secret = secret
50
- self.token = token
51
- end
52
-
53
- # mode can be either r to request read rights or w to request read/write rights.
54
- def permission_url(mode='w')
55
- "http://#{host}/admin/api/auth?api_key=#{key}&mode=#{mode}"
56
- end
57
-
58
- def apply!
59
- ActiveResource::Base.site = site if signed_in?
60
- end
61
-
62
- # use this to initialize ActiveResource:
63
- #
64
- # ActiveResource::Base.site = Shopify.current_session.site
65
- #
66
- def site
67
- "#{protocol}://#{key}:#{password}@#{host}/admin"
68
- end
69
-
70
- def signed_in?
71
- [host, key, secret, token].all?
72
- end
73
-
74
- private
75
-
76
- # The secret is computed by taking the shared_secret which we got when
77
- # registring this third party application and concating the request_to it,
78
- # and then calculating a MD5 hexdigest.
79
- def password
80
- Digest::MD5.hexdigest("#{secret.chomp}#{token.chomp}")
81
- end
82
- end
83
- end
data/lib/shopify/shop.rb DELETED
@@ -1,8 +0,0 @@
1
- module Shopify
2
- class Shop
3
- # Retrieves information from Shopify about your signed-in shop.
4
- def self.current
5
- ActiveResource::Base.find(:one, :from => "/admin/shop.xml")
6
- end
7
- end
8
- end
data/lib/shopify/site.rb DELETED
@@ -1,14 +0,0 @@
1
- module Shopify
2
- class Page < ActiveResource::Base
3
- end
4
-
5
- class Blog < ActiveResource::Base
6
- def articles
7
- Article.get
8
- end
9
- end
10
-
11
- class Article < ActiveResource::Base
12
- self.prefix = "/admin/blogs/:blog_id/"
13
- end
14
- end