shopify_api 4.2.0 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -5
- data/CHANGELOG +6 -0
- data/README.md +2 -0
- data/lib/shopify_api/resources/customer.rb +11 -0
- data/lib/shopify_api/resources/discount.rb +11 -0
- data/lib/shopify_api/resources/fulfillment.rb +5 -0
- data/lib/shopify_api/resources/refund.rb +13 -0
- data/lib/shopify_api/resources/user.rb +4 -0
- data/lib/shopify_api/version.rb +1 -1
- data/test/collect_test.rb +9 -0
- data/test/custom_collection_test.rb +9 -0
- data/test/customer_test.rb +12 -2
- data/test/discount_test.rb +52 -0
- data/test/fixtures/collect.json +12 -0
- data/test/fixtures/custom_collection.json +17 -0
- data/test/fixtures/customers.json +59 -0
- data/test/fixtures/customers_account_activation_url.json +3 -0
- data/test/fixtures/discount.json +17 -0
- data/test/fixtures/discount_disabled.json +17 -0
- data/test/fixtures/discounts.json +34 -0
- data/test/fixtures/redirect.json +7 -0
- data/test/fixtures/refund.json +112 -0
- data/test/fixtures/smart_collection.json +21 -0
- data/test/fixtures/user.json +21 -0
- data/test/fixtures/users.json +42 -0
- data/test/fulfillment_test.rb +22 -0
- data/test/redirect_test.rb +9 -0
- data/test/refund_test.rb +32 -0
- data/test/smart_collection_test.rb +10 -0
- data/test/user_test.rb +17 -0
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dde0dd1ec00e7646f6b4f75e6a6246798524e18
|
4
|
+
data.tar.gz: 10564e66476aa650ad5966f1be14e420ab3fec51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee2a33489d65026ea0cd8e14a0f25e16aad685465a7ec8e933c92e0269e31d43bd0c244f2f71fd86666699637563c7ab95b7cd0ad3215b19b2e3f418d2e4aa08
|
7
|
+
data.tar.gz: 4782ff90ba01c1a4949460a9aa02743903e1a1d66d9b644a3ab103eebefa01331be2a611e0ba655aafc8236becd4552cea42d6cc7b4a78c3794ce69cb95f2f56
|
data/.travis.yml
CHANGED
@@ -29,8 +29,3 @@ matrix:
|
|
29
29
|
- rvm: 1.9.2
|
30
30
|
gemfile: Gemfile_ar32
|
31
31
|
env: OLD_RAKE=1
|
32
|
-
|
33
|
-
|
34
|
-
notifications:
|
35
|
-
flowdock:
|
36
|
-
secure: "RCgSxzMScnqK6bOwkv9sWSdieLBeJla8NcDtM/QmuFW8soTgV6qCTAPAGd4lpjg4vGTaM3DsdHU5GMDbgdWN5dE2Rf09ayFqiZg8OloPMQ63KIwLJyVcw3cVJO5i7smjIpsSjPjBkvAXHIOFcKdsnuYGS4YD8hjl+QrZ3ghi440="
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -30,6 +30,8 @@ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveR
|
|
30
30
|
|
31
31
|
1. First create a new application in either the partners admin or your store admin. For a private App you'll need the API_KEY and the PASSWORD otherwise you'll need the API_KEY and SHARED_SECRET.
|
32
32
|
|
33
|
+
If you're not sure how to create a new application in the partner/store admin and/or if you're not sure how to generate the required credentials, you can [read the related shopify docs](https://docs.shopify.com/api/guides/api-credentials) on the same.
|
34
|
+
|
33
35
|
2. For a private App you just need to set the base site url as follows:
|
34
36
|
|
35
37
|
```ruby
|
@@ -9,5 +9,16 @@ module ShopifyAPI
|
|
9
9
|
def self.search(params)
|
10
10
|
find(:all, from: :search, params: params)
|
11
11
|
end
|
12
|
+
|
13
|
+
def account_activation_url
|
14
|
+
resource = post(:account_activation_url, {}, only_id)
|
15
|
+
data = ActiveSupport::JSON.decode(resource.body.to_s)
|
16
|
+
result = nil
|
17
|
+
|
18
|
+
if data.key?('account_activation_url')
|
19
|
+
result = data['account_activation_url']
|
20
|
+
end
|
21
|
+
result
|
22
|
+
end
|
12
23
|
end
|
13
24
|
end
|
@@ -2,7 +2,12 @@ module ShopifyAPI
|
|
2
2
|
class Fulfillment < Base
|
3
3
|
init_prefix :order
|
4
4
|
|
5
|
+
def order_id
|
6
|
+
@prefix_options[:order_id]
|
7
|
+
end
|
8
|
+
|
5
9
|
def cancel; load_attributes_from_response(post(:cancel, {}, only_id)); end
|
6
10
|
def complete; load_attributes_from_response(post(:complete, {}, only_id)); end
|
11
|
+
def open; load_attributes_from_response(post(:open, {}, only_id)); end
|
7
12
|
end
|
8
13
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ShopifyAPI
|
2
|
+
class Refund < Base
|
3
|
+
init_prefix :order
|
4
|
+
|
5
|
+
def self.calculate(*args)
|
6
|
+
options = { :refund => args[0] }
|
7
|
+
params = options.merge(args[1][:params]) if args[1] && args[1][:params]
|
8
|
+
self.prefix = "/admin/orders/#{params[:order_id]}/"
|
9
|
+
resource = post(:calculate, {}, options.to_json)
|
10
|
+
instantiate_record(format.decode(resource.body), {})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/shopify_api/version.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CollectTest < Test::Unit::TestCase
|
4
|
+
test "#create should create a collect" do
|
5
|
+
fake "collects", :method => :post, :status => 201, :body => load_fixture('collect')
|
6
|
+
link = ShopifyAPI::Collect.create(:product_id => 921728736, :collection_id => 841564295)
|
7
|
+
assert_equal 841564295, link.id
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CustomCollectionTest < Test::Unit::TestCase
|
4
|
+
test "#create should create a custom collection" do
|
5
|
+
fake "custom_collections", :method => :post, :status => 201, :body => load_fixture('custom_collection')
|
6
|
+
link = ShopifyAPI::CustomCollection.create(:title => "Macbooks", :image => { :src => "http://example.com/rails_logo.gif" })
|
7
|
+
assert_equal 1063001463, link.id
|
8
|
+
end
|
9
|
+
end
|
data/test/customer_test.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class CustomerTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
test "search should get a customers collection" do
|
6
|
+
fake "customers/search.json?query=Bob+country%3AUnited+States", :extension => false, :body => load_fixture('customers_search')
|
6
7
|
|
7
8
|
results = ShopifyAPI::Customer.search(query: 'Bob country:United States')
|
8
9
|
assert_equal 'Bob', results.first.first_name
|
9
10
|
end
|
11
|
+
|
12
|
+
test "account_activation_url should create an account activation url" do
|
13
|
+
fake "customers/207119551", :body => load_fixture('customers')
|
14
|
+
fake "customers/207119551/account_activation_url", :method => :post, :body => load_fixture('customers_account_activation_url')
|
15
|
+
|
16
|
+
customer = ShopifyAPI::Customer.find(207119551)
|
17
|
+
activation_url = "http://apple.myshopify.com/account/activate/207119551/86688abf23572680740b1c062fa37111-1458248616"
|
18
|
+
assert_equal activation_url, customer.account_activation_url
|
19
|
+
end
|
10
20
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DiscountTest < Test::Unit::TestCase
|
4
|
+
test 'get should get a discount' do
|
5
|
+
fake 'discounts/680866', method: :get, status: 200, body: load_fixture('discount')
|
6
|
+
|
7
|
+
discount = ShopifyAPI::Discount.find(680866)
|
8
|
+
assert_equal 680866, discount.id
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'get should get all discounts' do
|
12
|
+
fake 'discounts', method: :get, status: 200, body: load_fixture('discounts')
|
13
|
+
|
14
|
+
discounts = ShopifyAPI::Discount.all
|
15
|
+
assert_equal 'TENOFF', discounts.first.code
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'create should create a discount' do
|
19
|
+
fake 'discounts', method: :post, status: 201, body: load_fixture('discount')
|
20
|
+
|
21
|
+
discount = ShopifyAPI::Discount.create(code: 'TENOFF', discount_type: 'percentage')
|
22
|
+
assert_equal 'TENOFF', discount.code
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'should disable discount' do
|
26
|
+
fake 'discounts/680866', method: :get, status: 200, body: load_fixture('discount')
|
27
|
+
fake 'discounts/680866/disable', method: :post, status: 201, body: load_fixture('discount_disabled')
|
28
|
+
|
29
|
+
discount = ShopifyAPI::Discount.find(680866)
|
30
|
+
discount.disable
|
31
|
+
|
32
|
+
assert_equal "disabled", discount.status
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'should enable discount' do
|
36
|
+
fake 'discounts/680866', method: :get, status: 200, body: load_fixture('discount')
|
37
|
+
fake 'discounts/680866/enable', method: :post, status: 201, body: load_fixture('discount')
|
38
|
+
|
39
|
+
discount = ShopifyAPI::Discount.find(680866)
|
40
|
+
discount.enable
|
41
|
+
|
42
|
+
assert_equal "enabled", discount.status
|
43
|
+
end
|
44
|
+
|
45
|
+
test 'delete should delete discount' do
|
46
|
+
fake 'discounts/680866', method: :get, status: 200, body: load_fixture('discount')
|
47
|
+
fake 'discounts/680866', method: :delete, status: 200, body: 'destroyed'
|
48
|
+
|
49
|
+
discount = ShopifyAPI::Discount.find(680866)
|
50
|
+
assert discount.destroy
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"custom_collection": {
|
3
|
+
"id": 1063001463,
|
4
|
+
"handle": "macbooks",
|
5
|
+
"title": "Macbooks",
|
6
|
+
"updated_at": "2016-03-17T16:58:37-04:00",
|
7
|
+
"body_html": null,
|
8
|
+
"published_at": "2016-03-17T16:58:37-04:00",
|
9
|
+
"sort_order": "alpha-asc",
|
10
|
+
"template_suffix": null,
|
11
|
+
"published_scope": "global",
|
12
|
+
"image": {
|
13
|
+
"created_at": "2016-03-17T16:58:37-04:00",
|
14
|
+
"src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/collections\/fd43f2c8883f6e9b680e3295fd990d2c.gif?v=1458248317"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"customer": {
|
3
|
+
"id": 207119551,
|
4
|
+
"email": "bob.norman@hostmail.com",
|
5
|
+
"accepts_marketing": false,
|
6
|
+
"created_at": "2016-03-17T17:04:13-04:00",
|
7
|
+
"updated_at": "2016-03-17T17:04:13-04:00",
|
8
|
+
"first_name": "Bob",
|
9
|
+
"last_name": "Norman",
|
10
|
+
"orders_count": 1,
|
11
|
+
"state": "disabled",
|
12
|
+
"total_spent": "41.94",
|
13
|
+
"last_order_id": 450789469,
|
14
|
+
"note": null,
|
15
|
+
"verified_email": true,
|
16
|
+
"multipass_identifier": null,
|
17
|
+
"tax_exempt": false,
|
18
|
+
"tags": "",
|
19
|
+
"last_order_name": "#1001",
|
20
|
+
"default_address": {
|
21
|
+
"id": 207119551,
|
22
|
+
"first_name": null,
|
23
|
+
"last_name": null,
|
24
|
+
"company": null,
|
25
|
+
"address1": "Chestnut Street 92",
|
26
|
+
"address2": "",
|
27
|
+
"city": "Louisville",
|
28
|
+
"province": "Kentucky",
|
29
|
+
"country": "United States",
|
30
|
+
"zip": "40202",
|
31
|
+
"phone": "555-625-1199",
|
32
|
+
"name": "",
|
33
|
+
"province_code": "KY",
|
34
|
+
"country_code": "US",
|
35
|
+
"country_name": "United States",
|
36
|
+
"default": true
|
37
|
+
},
|
38
|
+
"addresses": [
|
39
|
+
{
|
40
|
+
"id": 207119551,
|
41
|
+
"first_name": null,
|
42
|
+
"last_name": null,
|
43
|
+
"company": null,
|
44
|
+
"address1": "Chestnut Street 92",
|
45
|
+
"address2": "",
|
46
|
+
"city": "Louisville",
|
47
|
+
"province": "Kentucky",
|
48
|
+
"country": "United States",
|
49
|
+
"zip": "40202",
|
50
|
+
"phone": "555-625-1199",
|
51
|
+
"name": "",
|
52
|
+
"province_code": "KY",
|
53
|
+
"country_code": "US",
|
54
|
+
"country_name": "United States",
|
55
|
+
"default": true
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"discount": {
|
3
|
+
"id": 680866,
|
4
|
+
"code": "TENOFF",
|
5
|
+
"value": "10.0",
|
6
|
+
"ends_at": null,
|
7
|
+
"starts_at": null,
|
8
|
+
"status": "enabled",
|
9
|
+
"minimum_order_amount": "0.00",
|
10
|
+
"usage_limit": null,
|
11
|
+
"applies_to_id": null,
|
12
|
+
"applies_once": false,
|
13
|
+
"discount_type": "percentage",
|
14
|
+
"applies_to_resource": null,
|
15
|
+
"times_used": 1
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"discount": {
|
3
|
+
"id": 680866,
|
4
|
+
"code": "TENOFF",
|
5
|
+
"value": "10.0",
|
6
|
+
"ends_at": null,
|
7
|
+
"starts_at": null,
|
8
|
+
"status": "disabled",
|
9
|
+
"minimum_order_amount": "0.00",
|
10
|
+
"usage_limit": null,
|
11
|
+
"applies_to_id": null,
|
12
|
+
"applies_once": false,
|
13
|
+
"discount_type": "percentage",
|
14
|
+
"applies_to_resource": null,
|
15
|
+
"times_used": 1
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"discounts": [
|
3
|
+
{
|
4
|
+
"id": 680866,
|
5
|
+
"code": "TENOFF",
|
6
|
+
"value": "10.0",
|
7
|
+
"ends_at": null,
|
8
|
+
"starts_at": null,
|
9
|
+
"status": "enabled",
|
10
|
+
"minimum_order_amount": "0.00",
|
11
|
+
"usage_limit": null,
|
12
|
+
"applies_to_id": null,
|
13
|
+
"applies_once": false,
|
14
|
+
"discount_type": "percentage",
|
15
|
+
"applies_to_resource": null,
|
16
|
+
"times_used": 1
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"id": 949676421,
|
20
|
+
"code": "xyz",
|
21
|
+
"value": "10.00",
|
22
|
+
"ends_at": null,
|
23
|
+
"starts_at": null,
|
24
|
+
"status": "disabled",
|
25
|
+
"minimum_order_amount": "0.00",
|
26
|
+
"usage_limit": null,
|
27
|
+
"applies_to_id": null,
|
28
|
+
"applies_once": false,
|
29
|
+
"discount_type": "fixed_amount",
|
30
|
+
"applies_to_resource": null,
|
31
|
+
"times_used": 0
|
32
|
+
}
|
33
|
+
]
|
34
|
+
}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
{
|
2
|
+
"refund": {
|
3
|
+
"id": 509562969,
|
4
|
+
"order_id": 450789469,
|
5
|
+
"created_at": "2016-03-22T11:15:00-04:00",
|
6
|
+
"note": "it broke during shipping",
|
7
|
+
"restock": true,
|
8
|
+
"user_id": 799407056,
|
9
|
+
"refund_line_items": [
|
10
|
+
{
|
11
|
+
"id": 104689539,
|
12
|
+
"quantity": 1,
|
13
|
+
"line_item_id": 703073504,
|
14
|
+
"line_item": {
|
15
|
+
"id": 703073504,
|
16
|
+
"variant_id": 457924702,
|
17
|
+
"title": "IPod Nano - 8gb",
|
18
|
+
"quantity": 1,
|
19
|
+
"price": "199.00",
|
20
|
+
"grams": 200,
|
21
|
+
"sku": "IPOD2008BLACK",
|
22
|
+
"variant_title": "black",
|
23
|
+
"vendor": null,
|
24
|
+
"fulfillment_service": "manual",
|
25
|
+
"product_id": 632910392,
|
26
|
+
"requires_shipping": true,
|
27
|
+
"taxable": true,
|
28
|
+
"gift_card": false,
|
29
|
+
"name": "IPod Nano - 8gb - black",
|
30
|
+
"variant_inventory_management": "shopify",
|
31
|
+
"properties": [
|
32
|
+
],
|
33
|
+
"product_exists": true,
|
34
|
+
"fulfillable_quantity": 1,
|
35
|
+
"total_discount": "0.00",
|
36
|
+
"fulfillment_status": null,
|
37
|
+
"tax_lines": [
|
38
|
+
{
|
39
|
+
"title": "State Tax",
|
40
|
+
"price": "3.98",
|
41
|
+
"rate": 0.06
|
42
|
+
}
|
43
|
+
]
|
44
|
+
}
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"id": 709875399,
|
48
|
+
"quantity": 1,
|
49
|
+
"line_item_id": 466157049,
|
50
|
+
"line_item": {
|
51
|
+
"id": 466157049,
|
52
|
+
"variant_id": 39072856,
|
53
|
+
"title": "IPod Nano - 8gb",
|
54
|
+
"quantity": 1,
|
55
|
+
"price": "199.00",
|
56
|
+
"grams": 200,
|
57
|
+
"sku": "IPOD2008GREEN",
|
58
|
+
"variant_title": "green",
|
59
|
+
"vendor": null,
|
60
|
+
"fulfillment_service": "manual",
|
61
|
+
"product_id": 632910392,
|
62
|
+
"requires_shipping": true,
|
63
|
+
"taxable": true,
|
64
|
+
"gift_card": false,
|
65
|
+
"name": "IPod Nano - 8gb - green",
|
66
|
+
"variant_inventory_management": "shopify",
|
67
|
+
"properties": [
|
68
|
+
{
|
69
|
+
"name": "Custom Engraving Front",
|
70
|
+
"value": "Happy Birthday"
|
71
|
+
}
|
72
|
+
],
|
73
|
+
"product_exists": true,
|
74
|
+
"fulfillable_quantity": 1,
|
75
|
+
"total_discount": "0.00",
|
76
|
+
"fulfillment_status": null,
|
77
|
+
"tax_lines": [
|
78
|
+
{
|
79
|
+
"title": "State Tax",
|
80
|
+
"price": "3.98",
|
81
|
+
"rate": 0.06
|
82
|
+
}
|
83
|
+
]
|
84
|
+
}
|
85
|
+
}
|
86
|
+
],
|
87
|
+
"transactions": [
|
88
|
+
{
|
89
|
+
"id": 179259969,
|
90
|
+
"order_id": 450789469,
|
91
|
+
"amount": "209.00",
|
92
|
+
"kind": "refund",
|
93
|
+
"gateway": "bogus",
|
94
|
+
"status": "success",
|
95
|
+
"message": null,
|
96
|
+
"created_at": "2005-08-05T12:59:12-04:00",
|
97
|
+
"test": false,
|
98
|
+
"authorization": "authorization-key",
|
99
|
+
"currency": "USD",
|
100
|
+
"location_id": null,
|
101
|
+
"user_id": null,
|
102
|
+
"parent_id": null,
|
103
|
+
"device_id": null,
|
104
|
+
"receipt": {},
|
105
|
+
"error_code": null,
|
106
|
+
"source_name": "web"
|
107
|
+
}
|
108
|
+
],
|
109
|
+
"order_adjustments": [
|
110
|
+
]
|
111
|
+
}
|
112
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"smart_collection": {
|
3
|
+
"id": 1063001432,
|
4
|
+
"handle": "macbooks",
|
5
|
+
"title": "Macbooks",
|
6
|
+
"updated_at": "2016-03-17T16:57:03-04:00",
|
7
|
+
"body_html": null,
|
8
|
+
"published_at": null,
|
9
|
+
"sort_order": "alpha-asc",
|
10
|
+
"template_suffix": null,
|
11
|
+
"published_scope": "global",
|
12
|
+
"disjunctive": false,
|
13
|
+
"rules": [
|
14
|
+
{
|
15
|
+
"column": "title",
|
16
|
+
"relation": "starts_with",
|
17
|
+
"condition": "mac"
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"user": {
|
3
|
+
"id": 799407056,
|
4
|
+
"first_name": "Steve",
|
5
|
+
"email": "steve@apple.com",
|
6
|
+
"url": "www.apple.com",
|
7
|
+
"im": null,
|
8
|
+
"screen_name": null,
|
9
|
+
"phone": null,
|
10
|
+
"last_name": "Jobs",
|
11
|
+
"account_owner": true,
|
12
|
+
"receive_announcements": 1,
|
13
|
+
"bio": null,
|
14
|
+
"permissions": [
|
15
|
+
"full"
|
16
|
+
],
|
17
|
+
"user_type": "regular",
|
18
|
+
"phone_validated?": false,
|
19
|
+
"tfa_enabled?": false
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
"users": [
|
3
|
+
{
|
4
|
+
"id": 799407056,
|
5
|
+
"first_name": "Steve",
|
6
|
+
"email": "steve@apple.com",
|
7
|
+
"url": "www.apple.com",
|
8
|
+
"im": null,
|
9
|
+
"screen_name": null,
|
10
|
+
"phone": null,
|
11
|
+
"last_name": "Jobs",
|
12
|
+
"account_owner": true,
|
13
|
+
"receive_announcements": 1,
|
14
|
+
"bio": null,
|
15
|
+
"permissions": [
|
16
|
+
"full"
|
17
|
+
],
|
18
|
+
"user_type": "regular",
|
19
|
+
"phone_validated?": false,
|
20
|
+
"tfa_enabled?": false
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"id": 930143300,
|
24
|
+
"first_name": "noaccesssteve",
|
25
|
+
"email": "noaccesssteve@jobs.com",
|
26
|
+
"url": "www.apple.com",
|
27
|
+
"im": null,
|
28
|
+
"screen_name": null,
|
29
|
+
"phone": null,
|
30
|
+
"last_name": "Jobs",
|
31
|
+
"account_owner": false,
|
32
|
+
"receive_announcements": 1,
|
33
|
+
"bio": null,
|
34
|
+
"permissions": [
|
35
|
+
"limited"
|
36
|
+
],
|
37
|
+
"user_type": "regular",
|
38
|
+
"phone_validated?": false,
|
39
|
+
"tfa_enabled?": false
|
40
|
+
}
|
41
|
+
]
|
42
|
+
}
|
data/test/fulfillment_test.rb
CHANGED
@@ -33,6 +33,28 @@ class FulFillmentTest < Test::Unit::TestCase
|
|
33
33
|
assert_equal 'cancelled', fulfillment.status
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
context "#open" do
|
38
|
+
should "be able to open a fulfillment" do
|
39
|
+
fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})
|
40
|
+
|
41
|
+
open_fulfillment = ActiveSupport::JSON.decode(load_fixture('fulfillment'))
|
42
|
+
open_fulfillment['fulfillment']['status'] = 'open'
|
43
|
+
fake "orders/450789469/fulfillments/255858046/open", :method => :post, :body => ActiveSupport::JSON.encode(open_fulfillment)
|
44
|
+
|
45
|
+
assert_equal 'pending', fulfillment.status
|
46
|
+
assert fulfillment.open
|
47
|
+
assert_equal 'open', fulfillment.status
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "#find" do
|
52
|
+
should "be able to find fulfillment" do
|
53
|
+
fulfillment = ShopifyAPI::Fulfillment.find(255858046, :params => {:order_id => 450789469})
|
54
|
+
assert_equal 255858046, fulfillment.id
|
55
|
+
assert_equal 450789469, fulfillment.order_id
|
56
|
+
end
|
57
|
+
end
|
36
58
|
end
|
37
59
|
|
38
60
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RedirectTest < Test::Unit::TestCase
|
4
|
+
test "#create should create a redirect" do
|
5
|
+
fake "redirects", :method => :post, :status => 201, :body => load_fixture('redirect')
|
6
|
+
redirect = ShopifyAPI::Redirect.create(:path => "/ipod", :target => "/pages/itunes")
|
7
|
+
assert_equal 979034150, redirect.id
|
8
|
+
end
|
9
|
+
end
|
data/test/refund_test.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RefundTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
test '#create should create a refund' do
|
6
|
+
fake "orders/450789469/refunds", :method => :post, :status => 201, :body => load_fixture('refund')
|
7
|
+
refund = ShopifyAPI::Refund.create(
|
8
|
+
:order_id => 450789469,
|
9
|
+
:restock => true,
|
10
|
+
:note => "wrong size",
|
11
|
+
:shipping => { :full_refund => true },
|
12
|
+
:refund_line_items => [{ :line_item => 518995019, :quantity => 1 }]
|
13
|
+
)
|
14
|
+
assert_equal 703073504, refund.refund_line_items.first.line_item_id
|
15
|
+
end
|
16
|
+
|
17
|
+
test '#find should return a refund' do
|
18
|
+
fake "orders/450789469/refunds/509562969.json?order_id=450789469", :extension => false, :method => :get, :body => load_fixture('refund')
|
19
|
+
fake "orders/450789469/refunds/509562969", :method => :get, :body => load_fixture('refund')
|
20
|
+
refund = ShopifyAPI::Refund.find(509562969, :params => {:order_id => 450789469})
|
21
|
+
assert_equal 509562969, refund.id
|
22
|
+
end
|
23
|
+
|
24
|
+
test '#calculate a refund' do
|
25
|
+
fake "orders/450789469/refunds/calculate", :method => :post, :body => load_fixture('refund')
|
26
|
+
data = { :shipping => { :amount => 0 } }
|
27
|
+
|
28
|
+
refund = ShopifyAPI::Refund.calculate(data, :params => {:order_id => 450789469})
|
29
|
+
assert_equal 2, refund.refund_line_items.count
|
30
|
+
assert_equal 703073504, refund.refund_line_items.first.line_item_id
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SmartCollectionTest < Test::Unit::TestCase
|
4
|
+
test "Smart Collection creation" do
|
5
|
+
fake "smart_collections", :method => :post, :status => 201, :body => load_fixture('smart_collection')
|
6
|
+
rules = { :column => "title", :relation => "starts_with", :condition => "mac" }
|
7
|
+
smart_collection = ShopifyAPI::SmartCollection.create(:title => "Macbooks", :rules => rules)
|
8
|
+
assert_equal 1063001432, smart_collection.id
|
9
|
+
end
|
10
|
+
end
|
data/test/user_test.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UserTest < Test::Unit::TestCase
|
4
|
+
test 'get should get a user' do
|
5
|
+
fake 'users/799407056', method: :get, status: 200, body: load_fixture('user')
|
6
|
+
|
7
|
+
user = ShopifyAPI::User.find(799407056)
|
8
|
+
assert_equal 799407056, user.id
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'get should get all users' do
|
12
|
+
fake 'users', method: :get, status: 200, body: load_fixture('users')
|
13
|
+
|
14
|
+
users = ShopifyAPI::User.all
|
15
|
+
assert_equal 799407056, users.first.id
|
16
|
+
end
|
17
|
+
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: 4.2.
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/shopify_api/resources/customer.rb
|
156
156
|
- lib/shopify_api/resources/customer_group.rb
|
157
157
|
- lib/shopify_api/resources/customer_saved_search.rb
|
158
|
+
- lib/shopify_api/resources/discount.rb
|
158
159
|
- lib/shopify_api/resources/event.rb
|
159
160
|
- lib/shopify_api/resources/fulfillment.rb
|
160
161
|
- lib/shopify_api/resources/fulfillment_event.rb
|
@@ -177,6 +178,7 @@ files:
|
|
177
178
|
- lib/shopify_api/resources/receipt.rb
|
178
179
|
- lib/shopify_api/resources/recurring_application_charge.rb
|
179
180
|
- lib/shopify_api/resources/redirect.rb
|
181
|
+
- lib/shopify_api/resources/refund.rb
|
180
182
|
- lib/shopify_api/resources/rule.rb
|
181
183
|
- lib/shopify_api/resources/script_tag.rb
|
182
184
|
- lib/shopify_api/resources/shipping_address.rb
|
@@ -189,6 +191,7 @@ files:
|
|
189
191
|
- lib/shopify_api/resources/theme.rb
|
190
192
|
- lib/shopify_api/resources/transaction.rb
|
191
193
|
- lib/shopify_api/resources/usage_charge.rb
|
194
|
+
- lib/shopify_api/resources/user.rb
|
192
195
|
- lib/shopify_api/resources/variant.rb
|
193
196
|
- lib/shopify_api/resources/webhook.rb
|
194
197
|
- lib/shopify_api/session.rb
|
@@ -204,9 +207,12 @@ files:
|
|
204
207
|
- test/carrier_service_test.rb
|
205
208
|
- test/cart_test.rb
|
206
209
|
- test/checkouts_test.rb
|
210
|
+
- test/collect_test.rb
|
211
|
+
- test/custom_collection_test.rb
|
207
212
|
- test/customer_saved_search_test.rb
|
208
213
|
- test/customer_test.rb
|
209
214
|
- test/detailed_log_subscriber_test.rb
|
215
|
+
- test/discount_test.rb
|
210
216
|
- test/fixtures/application_charge.json
|
211
217
|
- test/fixtures/application_charges.json
|
212
218
|
- test/fixtures/article.json
|
@@ -219,9 +225,16 @@ files:
|
|
219
225
|
- test/fixtures/carrier_service.json
|
220
226
|
- test/fixtures/carts.json
|
221
227
|
- test/fixtures/checkouts.json
|
228
|
+
- test/fixtures/collect.json
|
229
|
+
- test/fixtures/custom_collection.json
|
222
230
|
- test/fixtures/customer_saved_search.json
|
223
231
|
- test/fixtures/customer_saved_search_customers.json
|
232
|
+
- test/fixtures/customers.json
|
233
|
+
- test/fixtures/customers_account_activation_url.json
|
224
234
|
- test/fixtures/customers_search.json
|
235
|
+
- test/fixtures/discount.json
|
236
|
+
- test/fixtures/discount_disabled.json
|
237
|
+
- test/fixtures/discounts.json
|
225
238
|
- test/fixtures/events.json
|
226
239
|
- test/fixtures/fulfillment.json
|
227
240
|
- test/fixtures/fulfillment_event.json
|
@@ -242,15 +255,20 @@ files:
|
|
242
255
|
- test/fixtures/recurring_application_charge.json
|
243
256
|
- test/fixtures/recurring_application_charge_adjustment.json
|
244
257
|
- test/fixtures/recurring_application_charges.json
|
258
|
+
- test/fixtures/redirect.json
|
259
|
+
- test/fixtures/refund.json
|
245
260
|
- test/fixtures/script_tag.json
|
246
261
|
- test/fixtures/script_tags.json
|
247
262
|
- test/fixtures/shipping_zones.json
|
248
263
|
- test/fixtures/shop.json
|
264
|
+
- test/fixtures/smart_collection.json
|
249
265
|
- test/fixtures/tags.json
|
250
266
|
- test/fixtures/tax_service.json
|
251
267
|
- test/fixtures/transaction.json
|
252
268
|
- test/fixtures/usage_charge.json
|
253
269
|
- test/fixtures/usage_charges.json
|
270
|
+
- test/fixtures/user.json
|
271
|
+
- test/fixtures/users.json
|
254
272
|
- test/fixtures/variant.json
|
255
273
|
- test/fixtures/variants.json
|
256
274
|
- test/fixtures/webhook.json
|
@@ -268,14 +286,18 @@ files:
|
|
268
286
|
- test/policy_test.rb
|
269
287
|
- test/product_test.rb
|
270
288
|
- test/recurring_application_charge_test.rb
|
289
|
+
- test/redirect_test.rb
|
290
|
+
- test/refund_test.rb
|
271
291
|
- test/script_tag_test.rb
|
272
292
|
- test/session_test.rb
|
273
293
|
- test/shipping_zone_test.rb
|
274
294
|
- test/shop_test.rb
|
295
|
+
- test/smart_collection_test.rb
|
275
296
|
- test/tax_service_test.rb
|
276
297
|
- test/test_helper.rb
|
277
298
|
- test/transaction_test.rb
|
278
299
|
- test/usage_charge_test.rb
|
300
|
+
- test/user_test.rb
|
279
301
|
- test/variant_test.rb
|
280
302
|
- test/webhook_test.rb
|
281
303
|
homepage: http://www.shopify.com/partners/apps
|