shopify_api 4.0.0 → 4.0.1
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG +5 -1
- data/Gemfile.lock +1 -1
- data/lib/shopify_api/resources/gift_card.rb +7 -0
- data/lib/shopify_api/resources/o_auth.rb +9 -0
- data/lib/shopify_api/resources/shop.rb +2 -2
- data/lib/shopify_api/session.rb +4 -3
- data/lib/shopify_api/version.rb +1 -1
- data/test/fixtures/gift_card.json +20 -0
- data/test/fixtures/gift_card_disabled.json +20 -0
- data/test/fixtures/o_auth_revoke.json +5 -0
- data/test/gift_card_test.rb +22 -0
- data/test/o_auth_test.rb +8 -0
- data/test/session_test.rb +9 -9
- data/test/shop_test.rb +9 -0
- metadata +9 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f83cb9b80cf63282dd34ebaebc6c7623f9c54778
|
4
|
+
data.tar.gz: 281e61d77b3e56c4823bdab49fe8d7d400b240c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b87bc82865feaf0f54e6132d8794bc926bf31ab3e980b857577ec4c9855a10e2d09207e379db9ac912d5707f85c1e23ece857cf987025d9aa780b6ea3a85a02e
|
7
|
+
data.tar.gz: b9e4cd9e1001a1ddd539ce796448359f78ef5eb9643360be17c4f03b939a2572fc331afd91c073b37b8f434e977bcd1b927aa2ee4660efb9123265ce9fa5caac
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,8 +2,8 @@ module ShopifyAPI
|
|
2
2
|
# Shop object. Use Shop.current to receive
|
3
3
|
# the shop.
|
4
4
|
class Shop < Base
|
5
|
-
def self.current
|
6
|
-
find(:one, from: "/admin/shop.#{format.extension}")
|
5
|
+
def self.current(options={})
|
6
|
+
find(:one, options.merge({from: "/admin/shop.#{format.extension}"}))
|
7
7
|
end
|
8
8
|
|
9
9
|
def metafields
|
data/lib/shopify_api/session.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'openssl'
|
1
2
|
|
2
3
|
module ShopifyAPI
|
3
4
|
|
@@ -43,10 +44,10 @@ module ShopifyAPI
|
|
43
44
|
|
44
45
|
def validate_signature(params)
|
45
46
|
params = params.with_indifferent_access
|
46
|
-
return false unless signature = params[:
|
47
|
+
return false unless signature = params[:hmac]
|
47
48
|
|
48
|
-
sorted_params = params.except(:signature, :action, :controller).collect{|k,v|"#{k}=#{v}"}.sort.join
|
49
|
-
|
49
|
+
sorted_params = params.except(:signature, :hmac, :action, :controller).collect{|k,v|"#{k}=#{v}"}.sort.join('&')
|
50
|
+
OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), secret, sorted_params) == signature
|
50
51
|
end
|
51
52
|
|
52
53
|
def host_with_port(site)
|
data/lib/shopify_api/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"gift_card": {
|
3
|
+
"api_client_id": null,
|
4
|
+
"balance": "10.00",
|
5
|
+
"created_at": "2014-08-06T15:58:38-03:00",
|
6
|
+
"currency": "CAD",
|
7
|
+
"customer_id": null,
|
8
|
+
"disabled_at": null,
|
9
|
+
"expires_on": null,
|
10
|
+
"id": 1023670,
|
11
|
+
"initial_value": "10.00",
|
12
|
+
"line_item_id": null,
|
13
|
+
"note": "",
|
14
|
+
"template_suffix": "",
|
15
|
+
"updated_at": "2014-08-06T15:58:38-03:00",
|
16
|
+
"user_id": 2699672,
|
17
|
+
"last_characters": "dddd",
|
18
|
+
"order_id": null
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"gift_card": {
|
3
|
+
"api_client_id": null,
|
4
|
+
"balance": "10.00",
|
5
|
+
"created_at": "2014-08-06T15:58:38-03:00",
|
6
|
+
"currency": "CAD",
|
7
|
+
"customer_id": null,
|
8
|
+
"disabled_at": "2014-09-13T20:15:21-03:00",
|
9
|
+
"expires_on": null,
|
10
|
+
"id": 1023670,
|
11
|
+
"initial_value": "10.00",
|
12
|
+
"line_item_id": null,
|
13
|
+
"note": "",
|
14
|
+
"template_suffix": "",
|
15
|
+
"updated_at": "2014-09-13T20:15:21-03:00",
|
16
|
+
"user_id": 2699672,
|
17
|
+
"last_characters": "dddd",
|
18
|
+
"order_id": null
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class GiftCardTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
load_gift_card
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_disable
|
10
|
+
fake 'gift_cards/1023670/disable.json', :body => load_fixture('gift_card_disabled'), :method => :post, :extension => false
|
11
|
+
|
12
|
+
refute @gift_card.disabled_at
|
13
|
+
@gift_card.disable
|
14
|
+
assert @gift_card.disabled_at
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def load_gift_card
|
19
|
+
fake 'gift_cards/1023670', :body => load_fixture('gift_card')
|
20
|
+
@gift_card = ShopifyAPI::GiftCard.find(1023670)
|
21
|
+
end
|
22
|
+
end
|
data/test/o_auth_test.rb
ADDED
data/test/session_test.rb
CHANGED
@@ -117,10 +117,10 @@ class SessionTest < Test::Unit::TestCase
|
|
117
117
|
ShopifyAPI::Session.secret = 'secret'
|
118
118
|
params = {:code => 'any-code', :timestamp => Time.now}
|
119
119
|
sorted_params = make_sorted_params(params)
|
120
|
-
signature =
|
120
|
+
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
|
121
121
|
fake nil, :url => 'https://testshop.myshopify.com/admin/oauth/access_token',:method => :post, :body => '{"access_token" : "any-token"}'
|
122
122
|
session = ShopifyAPI::Session.new("testshop.myshopify.com")
|
123
|
-
token = session.request_token(params.merge(:
|
123
|
+
token = session.request_token(params.merge(:hmac => signature))
|
124
124
|
assert_equal "any-token", token
|
125
125
|
end
|
126
126
|
|
@@ -128,11 +128,11 @@ class SessionTest < Test::Unit::TestCase
|
|
128
128
|
ShopifyAPI::Session.secret = 'secret'
|
129
129
|
params = {:code => "any-code", :timestamp => Time.now}
|
130
130
|
sorted_params = make_sorted_params(params)
|
131
|
-
signature =
|
131
|
+
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
|
132
132
|
params[:foo] = 'world'
|
133
133
|
assert_raises(ShopifyAPI::ValidationException) do
|
134
134
|
session = ShopifyAPI::Session.new("testshop.myshopify.com")
|
135
|
-
session.request_token(params.merge(:
|
135
|
+
session.request_token(params.merge(:hmac => signature))
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -140,11 +140,11 @@ class SessionTest < Test::Unit::TestCase
|
|
140
140
|
ShopifyAPI::Session.secret = 'secret'
|
141
141
|
params = {:code => "any-code", :timestamp => Time.now - 2.days}
|
142
142
|
sorted_params = make_sorted_params(params)
|
143
|
-
signature =
|
143
|
+
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
|
144
144
|
params[:foo] = 'world'
|
145
145
|
assert_raises(ShopifyAPI::ValidationException) do
|
146
146
|
session = ShopifyAPI::Session.new("testshop.myshopify.com")
|
147
|
-
session.request_token(params.merge(:
|
147
|
+
session.request_token(params.merge(:hmac => signature))
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
@@ -152,8 +152,8 @@ class SessionTest < Test::Unit::TestCase
|
|
152
152
|
now = Time.now
|
153
153
|
params = {"code" => "any-code", "timestamp" => now}
|
154
154
|
sorted_params = make_sorted_params(params)
|
155
|
-
signature =
|
156
|
-
params = {"code" => "any-code", "timestamp" => now, "
|
155
|
+
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new(), ShopifyAPI::Session.secret, sorted_params)
|
156
|
+
params = {"code" => "any-code", "timestamp" => now, "hmac" => signature}
|
157
157
|
|
158
158
|
assert_equal true, ShopifyAPI::Session.validate_signature(params)
|
159
159
|
end
|
@@ -161,7 +161,7 @@ class SessionTest < Test::Unit::TestCase
|
|
161
161
|
private
|
162
162
|
|
163
163
|
def make_sorted_params(params)
|
164
|
-
sorted_params = params.with_indifferent_access.except(:signature, :action, :controller).collect{|k,v|"#{k}=#{v}"}.sort.join
|
164
|
+
sorted_params = params.with_indifferent_access.except(:signature, :hmac, :action, :controller).collect{|k,v|"#{k}=#{v}"}.sort.join('&')
|
165
165
|
end
|
166
166
|
|
167
167
|
end
|
data/test/shop_test.rb
CHANGED
@@ -16,6 +16,15 @@ class ShopTest < Test::Unit::TestCase
|
|
16
16
|
assert_nil @shop.tax_shipping
|
17
17
|
end
|
18
18
|
|
19
|
+
def test_current_with_options_should_return_current_shop
|
20
|
+
fake "shop.json?fields%5B%5D=name&fields%5B%5D=myshopify_domain", :extension => false, :method => :get, :status => 201, :body => load_fixture('shop')
|
21
|
+
|
22
|
+
@shop = ShopifyAPI::Shop.current(params: { fields: [:name, :myshopify_domain]})
|
23
|
+
assert @shop.is_a?(ShopifyAPI::Shop)
|
24
|
+
assert_equal "Apple Computers", @shop.name
|
25
|
+
assert_equal "apple.myshopify.com", @shop.myshopify_domain
|
26
|
+
end
|
27
|
+
|
19
28
|
def test_get_metafields_for_shop
|
20
29
|
fake "metafields"
|
21
30
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
fl3hbtVFTqbOlwL9vy1fudXcolIE/ZTcxQ+er07ZFZdKCXayR9PPs64heamfn0fp
|
31
31
|
TConQSX2BnZdhIEYW+cKzEC/bLc=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-04
|
33
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: activeresource
|
@@ -165,11 +165,13 @@ files:
|
|
165
165
|
- lib/shopify_api/resources/event.rb
|
166
166
|
- lib/shopify_api/resources/fulfillment.rb
|
167
167
|
- lib/shopify_api/resources/fulfillment_service.rb
|
168
|
+
- lib/shopify_api/resources/gift_card.rb
|
168
169
|
- lib/shopify_api/resources/image.rb
|
169
170
|
- lib/shopify_api/resources/line_item.rb
|
170
171
|
- lib/shopify_api/resources/location.rb
|
171
172
|
- lib/shopify_api/resources/metafield.rb
|
172
173
|
- lib/shopify_api/resources/note_attribute.rb
|
174
|
+
- lib/shopify_api/resources/o_auth.rb
|
173
175
|
- lib/shopify_api/resources/option.rb
|
174
176
|
- lib/shopify_api/resources/order.rb
|
175
177
|
- lib/shopify_api/resources/order_risk.rb
|
@@ -223,10 +225,13 @@ files:
|
|
223
225
|
- test/fixtures/events.json
|
224
226
|
- test/fixtures/fulfillment.json
|
225
227
|
- test/fixtures/fulfillment_service.json
|
228
|
+
- test/fixtures/gift_card.json
|
229
|
+
- test/fixtures/gift_card_disabled.json
|
226
230
|
- test/fixtures/image.json
|
227
231
|
- test/fixtures/images.json
|
228
232
|
- test/fixtures/metafield.json
|
229
233
|
- test/fixtures/metafields.json
|
234
|
+
- test/fixtures/o_auth_revoke.json
|
230
235
|
- test/fixtures/order.json
|
231
236
|
- test/fixtures/order_risk.json
|
232
237
|
- test/fixtures/order_risks.json
|
@@ -246,9 +251,11 @@ files:
|
|
246
251
|
- test/fixtures/webhooks.json
|
247
252
|
- test/fulfillment_service_test.rb
|
248
253
|
- test/fulfillment_test.rb
|
254
|
+
- test/gift_card_test.rb
|
249
255
|
- test/image_test.rb
|
250
256
|
- test/limits_test.rb
|
251
257
|
- test/metafield_test.rb
|
258
|
+
- test/o_auth_test.rb
|
252
259
|
- test/order_risk_test.rb
|
253
260
|
- test/order_test.rb
|
254
261
|
- test/policy_test.rb
|
metadata.gz.sig
CHANGED
Binary file
|