shopify_api 3.2.1 → 3.2.2
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
- data/CHANGELOG +5 -0
- data/Gemfile.lock +3 -2
- data/lib/shopify_api/cli.rb +20 -19
- data/lib/shopify_api/session.rb +4 -1
- data/lib/shopify_api/version.rb +1 -1
- data/shopify_api.gemspec +4 -2
- data/test/checkouts_test.rb +9 -0
- data/test/cli_test.rb +24 -24
- data/test/fixtures/checkouts.json +186 -0
- data/test/fixtures/order.json +297 -0
- data/test/fixtures/orders.json +299 -0
- data/test/fixtures/script_tag.json +10 -0
- data/test/fixtures/script_tags.json +18 -0
- data/test/fixtures/webhook.json +10 -0
- data/test/fixtures/webhooks.json +18 -0
- data/test/order_test.rb +24 -40
- data/test/script_tag_test.rb +30 -0
- data/test/session_test.rb +4 -4
- data/test/webhook_test.rb +21 -0
- metadata +31 -7
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"script_tags": [
|
3
|
+
{
|
4
|
+
"created_at": "2014-03-07T16:14:54-05:00",
|
5
|
+
"event": "onload",
|
6
|
+
"id": 421379493,
|
7
|
+
"src": "http://js-aplenty.com/bar.js",
|
8
|
+
"updated_at": "2014-03-07T16:14:54-05:00"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"created_at": "2014-03-07T16:14:54-05:00",
|
12
|
+
"event": "onload",
|
13
|
+
"id": 596726825,
|
14
|
+
"src": "http://js-aplenty.com/foo.js",
|
15
|
+
"updated_at": "2014-03-07T16:14:54-05:00"
|
16
|
+
}
|
17
|
+
]
|
18
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"webhooks":[{
|
3
|
+
"address":"http://www.yoloship.it/webhook",
|
4
|
+
"created_at":"2014-02-11T12:13:55-05:00",
|
5
|
+
"format":"json",
|
6
|
+
"id":123456,
|
7
|
+
"topic":"orders/create",
|
8
|
+
"updated_at":"2014-02-11T12:13:55-05:00"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"address":"http://www.yoloship.it/webhook",
|
12
|
+
"created_at":"2014-02-11T12:13:55-05:00",
|
13
|
+
"format":"json",
|
14
|
+
"id":123456,
|
15
|
+
"topic":"orders/create",
|
16
|
+
"updated_at":"2014-02-11T12:13:55-05:00"
|
17
|
+
}]
|
18
|
+
}
|
data/test/order_test.rb
CHANGED
@@ -1,48 +1,32 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class OrderTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
ActiveResource::Base.site = "http://localhost"
|
6
|
-
end
|
7
|
-
|
8
|
-
context "Order" do
|
9
|
-
context "#note_attributes" do
|
10
4
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<note-attribute>
|
17
|
-
<name>size</name>
|
18
|
-
<value>large</value>
|
19
|
-
</note-attribute>
|
20
|
-
</note-attributes>
|
21
|
-
</order>
|
22
|
-
XML
|
5
|
+
test "create should create order" do
|
6
|
+
fake 'orders', :method => :post, :status => 201, :body => load_fixture('order')
|
7
|
+
order = ShopifyAPI::Order.create(line_items: [{quantity:1, variant_id:39072856}], financial_status:"authorized")
|
8
|
+
assert_equal 39072856, order.line_items.first.variant_id
|
9
|
+
end
|
23
10
|
|
24
|
-
|
11
|
+
test "get should get an order" do
|
12
|
+
fake 'orders/450789469', :method => :get, :status => 200, :body => load_fixture('order')
|
13
|
+
order = ShopifyAPI::Order.find(450789469)
|
14
|
+
assert_equal 450789469, order.id
|
15
|
+
end
|
25
16
|
|
26
|
-
|
17
|
+
test "get all should get all orders" do
|
18
|
+
fake 'orders', :method => :get, :status => 200, :body => load_fixture('orders')
|
19
|
+
order = ShopifyAPI::Order.all
|
20
|
+
assert_equal 450789469, order.first.id
|
21
|
+
end
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
order.note_attributes = []
|
36
|
-
order.note_attributes << ShopifyAPI::NoteAttribute.new(:name => "color", :value => "blue")
|
37
|
-
|
38
|
-
order_xml = Hash.from_xml(order.to_xml)
|
39
|
-
assert note_attributes = order_xml["order"]["note_attributes"]
|
40
|
-
assert_instance_of Array, note_attributes
|
41
|
-
|
42
|
-
attribute = note_attributes.first
|
43
|
-
assert_equal "color", attribute["name"]
|
44
|
-
assert_equal "blue", attribute["value"]
|
45
|
-
end
|
46
|
-
end
|
23
|
+
test "add note should add a note to order" do
|
24
|
+
fake 'orders/450789469', :method => :get, :status => 200, :body => load_fixture('order')
|
25
|
+
order = ShopifyAPI::Order.find(450789469)
|
26
|
+
order.note = "Test note"
|
27
|
+
fake 'orders/450789469', :method => :put, :status => 200, :body => load_fixture('order')
|
28
|
+
order.save
|
29
|
+
assert_equal "Test note", order.note
|
47
30
|
end
|
48
|
-
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ScriptTagTest < Test::Unit::TestCase
|
4
|
+
test "get all should get all script tags" do
|
5
|
+
fake 'script_tags', :method => :get, :status => 200, :body => load_fixture('script_tags')
|
6
|
+
script_tags = ShopifyAPI::ScriptTag.all
|
7
|
+
assert_equal "http://js-aplenty.com/bar.js", script_tags.first.src
|
8
|
+
end
|
9
|
+
|
10
|
+
test "get should get a script tag" do
|
11
|
+
fake 'script_tags/421379493', :method => :get, :status => 200, :body => load_fixture('script_tag')
|
12
|
+
script_tag = ShopifyAPI::ScriptTag.find(421379493)
|
13
|
+
assert_equal "http://js-aplenty.com/bar.js", script_tag.src
|
14
|
+
end
|
15
|
+
|
16
|
+
test "create should create a new script tag" do
|
17
|
+
fake 'script_tags', :method => :post, :status => 201, :body => load_fixture('script_tag')
|
18
|
+
script_tag = ShopifyAPI::ScriptTag.create(event: "onload", src: "http://js-aplenty.com/bar.js")
|
19
|
+
assert_equal "http://js-aplenty.com/bar.js", script_tag.src
|
20
|
+
end
|
21
|
+
|
22
|
+
test "editing script tag should update script tag" do
|
23
|
+
fake 'script_tags/421379493', :method => :get, :status => 200, :body => load_fixture('script_tag')
|
24
|
+
script_tag = ShopifyAPI::ScriptTag.find(421379493)
|
25
|
+
script_tag.src = "http://js-aplenty.com/bar.js"
|
26
|
+
fake 'script_tags/421379493', :method => :put, :status => 200, :body => load_fixture('script_tag')
|
27
|
+
script_tag.save
|
28
|
+
assert_equal "http://js-aplenty.com/bar.js", script_tag.src
|
29
|
+
end
|
30
|
+
end
|
data/test/session_test.rb
CHANGED
@@ -25,7 +25,7 @@ class SessionTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
should "raise error if params passed but signature omitted" do
|
28
|
-
assert_raises(
|
28
|
+
assert_raises(ShopifyAPI::ValidationException) do
|
29
29
|
session = ShopifyAPI::Session.new("testshop.myshopify.com")
|
30
30
|
session.request_token({'code' => 'any-code'})
|
31
31
|
end
|
@@ -90,7 +90,7 @@ class SessionTest < Test::Unit::TestCase
|
|
90
90
|
ShopifyAPI::Session.setup(:api_key => "My test key", :secret => "My test secret")
|
91
91
|
session = ShopifyAPI::Session.new('http://localhost.myshopify.com')
|
92
92
|
fake nil, :url => 'https://localhost.myshopify.com/admin/oauth/access_token',:method => :post, :status => 404, :body => '{"error" : "invalid_request"}'
|
93
|
-
assert_raises(
|
93
|
+
assert_raises(ShopifyAPI::ValidationException) do
|
94
94
|
session.request_token(params={:code => "bad-code"})
|
95
95
|
end
|
96
96
|
assert_equal false, session.valid?
|
@@ -130,7 +130,7 @@ class SessionTest < Test::Unit::TestCase
|
|
130
130
|
sorted_params = make_sorted_params(params)
|
131
131
|
signature = Digest::MD5.hexdigest(ShopifyAPI::Session.secret + sorted_params)
|
132
132
|
params[:foo] = 'world'
|
133
|
-
assert_raises(
|
133
|
+
assert_raises(ShopifyAPI::ValidationException) do
|
134
134
|
session = ShopifyAPI::Session.new("testshop.myshopify.com")
|
135
135
|
session.request_token(params.merge(:signature => signature))
|
136
136
|
end
|
@@ -142,7 +142,7 @@ class SessionTest < Test::Unit::TestCase
|
|
142
142
|
sorted_params = make_sorted_params(params)
|
143
143
|
signature = Digest::MD5.hexdigest(ShopifyAPI::Session.secret + sorted_params)
|
144
144
|
params[:foo] = 'world'
|
145
|
-
assert_raises(
|
145
|
+
assert_raises(ShopifyAPI::ValidationException) do
|
146
146
|
session = ShopifyAPI::Session.new("testshop.myshopify.com")
|
147
147
|
session.request_token(params.merge(:signature => signature))
|
148
148
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class WebhookTest < Test::Unit::TestCase
|
4
|
+
test 'create should create a webhook' do
|
5
|
+
fake 'webhooks', :method => :post, :status => 201, :body => load_fixture('webhook')
|
6
|
+
webhook = ShopifyAPI::Webhook.create(address: "http://www.yoloship.it/webhook", topic: "orders/create", format: "json")
|
7
|
+
assert_equal "http://www.yoloship.it/webhook", webhook.address
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'get should retrieve a webhook' do
|
11
|
+
fake 'webhooks/123456', :method => :get, :status => 200, :body => load_fixture('webhook')
|
12
|
+
webhook = ShopifyAPI::Webhook.find(123456)
|
13
|
+
assert_equal "http://www.yoloship.it/webhook", webhook.address
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'find all should return all webhooks' do
|
17
|
+
fake 'webhooks', :method => :get, :status => 200, :body => load_fixture('webhooks')
|
18
|
+
webhook = ShopifyAPI::Webhook.all
|
19
|
+
assert_equal 123456, webhook.first.id
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.18.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.18.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mocha
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,6 +193,7 @@ files:
|
|
179
193
|
- test/blog_test.rb
|
180
194
|
- test/carrier_service_test.rb
|
181
195
|
- test/cart_test.rb
|
196
|
+
- test/checkouts_test.rb
|
182
197
|
- test/cli_test.rb
|
183
198
|
- test/customer_saved_search_test.rb
|
184
199
|
- test/customer_test.rb
|
@@ -192,6 +207,7 @@ files:
|
|
192
207
|
- test/fixtures/blogs.json
|
193
208
|
- test/fixtures/carrier_service.json
|
194
209
|
- test/fixtures/carts.json
|
210
|
+
- test/fixtures/checkouts.json
|
195
211
|
- test/fixtures/customer_saved_search.json
|
196
212
|
- test/fixtures/customer_saved_search_customers.json
|
197
213
|
- test/fixtures/customers_search.json
|
@@ -202,16 +218,22 @@ files:
|
|
202
218
|
- test/fixtures/images.json
|
203
219
|
- test/fixtures/metafield.json
|
204
220
|
- test/fixtures/metafields.json
|
221
|
+
- test/fixtures/order.json
|
205
222
|
- test/fixtures/order_risk.json
|
206
223
|
- test/fixtures/order_risks.json
|
224
|
+
- test/fixtures/orders.json
|
207
225
|
- test/fixtures/product.json
|
208
226
|
- test/fixtures/recurring_application_charge.json
|
209
227
|
- test/fixtures/recurring_application_charges.json
|
228
|
+
- test/fixtures/script_tag.json
|
229
|
+
- test/fixtures/script_tags.json
|
210
230
|
- test/fixtures/shop.json
|
211
231
|
- test/fixtures/tags.json
|
212
232
|
- test/fixtures/transaction.json
|
213
233
|
- test/fixtures/variant.json
|
214
234
|
- test/fixtures/variants.json
|
235
|
+
- test/fixtures/webhook.json
|
236
|
+
- test/fixtures/webhooks.json
|
215
237
|
- test/fulfillment_service_test.rb
|
216
238
|
- test/fulfillment_test.rb
|
217
239
|
- test/image_test.rb
|
@@ -220,11 +242,13 @@ files:
|
|
220
242
|
- test/order_test.rb
|
221
243
|
- test/product_test.rb
|
222
244
|
- test/recurring_application_charge_test.rb
|
245
|
+
- test/script_tag_test.rb
|
223
246
|
- test/session_test.rb
|
224
247
|
- test/shop_test.rb
|
225
248
|
- test/test_helper.rb
|
226
249
|
- test/transaction_test.rb
|
227
250
|
- test/variant_test.rb
|
251
|
+
- test/webhook_test.rb
|
228
252
|
homepage: http://www.shopify.com/partners/apps
|
229
253
|
licenses:
|
230
254
|
- MIT
|
@@ -246,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
270
|
version: '0'
|
247
271
|
requirements: []
|
248
272
|
rubyforge_project:
|
249
|
-
rubygems_version: 2.2.
|
273
|
+
rubygems_version: 2.2.2
|
250
274
|
signing_key:
|
251
275
|
specification_version: 4
|
252
276
|
summary: ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web
|