shopify_api 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16a1cc4645fabc273ed6949ec27ccb17a3381488
4
- data.tar.gz: ff56c49090a74e23cafb17bdbf941b04124604bb
3
+ metadata.gz: f83cb9b80cf63282dd34ebaebc6c7623f9c54778
4
+ data.tar.gz: 281e61d77b3e56c4823bdab49fe8d7d400b240c7
5
5
  SHA512:
6
- metadata.gz: 6d0f540c231f47f5b239b7937578588f3e31d3df00156a2aeb199817969f02eb74bc89c5cca65b16f84a5ecac5e0eb8012a47e46f0d01722b1914eb5a08a80b0
7
- data.tar.gz: 4fb110853ebf1eec0247ecd5b9f132ac6a9a69f677ac1aebac076a8b27f7eece474a0279e300328997284d41d5edfaf16346175232157d206bdec1ab78c9f404
6
+ metadata.gz: b87bc82865feaf0f54e6132d8794bc926bf31ab3e980b857577ec4c9855a10e2d09207e379db9ac912d5707f85c1e23ece857cf987025d9aa780b6ea3a85a02e
7
+ data.tar.gz: b9e4cd9e1001a1ddd539ce796448359f78ef5eb9643360be17c4f03b939a2572fc331afd91c073b37b8f434e977bcd1b927aa2ee4660efb9123265ce9fa5caac
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,4 +1,8 @@
1
- == 3.2.6 (Unreleased)
1
+ == Version 4.0.1
2
+
3
+ * Added `ShopifyAPI::OAuth.revoke` for easy token revocation.
4
+
5
+ == Version 3.2.6
2
6
 
3
7
  * Fixed CustomerSavedSearch#customers method to now correctly return only relevant customers
4
8
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify_api (4.0.0)
4
+ shopify_api (4.0.1)
5
5
  activeresource
6
6
 
7
7
  GEM
@@ -0,0 +1,7 @@
1
+ module ShopifyAPI
2
+ class GiftCard < Base
3
+ def disable
4
+ load_attributes_from_response(post(:disable))
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module ShopifyAPI
2
+ class OAuth < Base
3
+ self.collection_name = 'oauth'
4
+
5
+ def self.revoke
6
+ delete(:revoke)
7
+ end
8
+ end
9
+ end
@@ -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
@@ -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[:signature]
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
- Digest::MD5.hexdigest(secret + sorted_params) == signature
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)
@@ -1,3 +1,3 @@
1
1
  module ShopifyAPI
2
- VERSION = "4.0.0"
2
+ VERSION = "4.0.1"
3
3
  end
@@ -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,5 @@
1
+ {
2
+ "permission": {
3
+ "access_token": "8ccb0232e04c672bf044f71ff0156098"
4
+ }
5
+ }
@@ -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
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class OAuthTest < Test::Unit::TestCase
4
+ def test_revoke_kills_the_token
5
+ fake 'oauth/revoke', method: :delete, body: load_fixture('o_auth_revoke')
6
+ assert ShopifyAPI::OAuth.revoke
7
+ end
8
+ end
@@ -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 = Digest::MD5.hexdigest(ShopifyAPI::Session.secret + sorted_params)
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(:signature => signature))
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 = Digest::MD5.hexdigest(ShopifyAPI::Session.secret + sorted_params)
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(:signature => signature))
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 = Digest::MD5.hexdigest(ShopifyAPI::Session.secret + sorted_params)
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(:signature => signature))
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 = Digest::MD5.hexdigest(ShopifyAPI::Session.secret + sorted_params)
156
- params = {"code" => "any-code", "timestamp" => now, "signature" => signature}
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
@@ -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.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-22 00:00:00.000000000 Z
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