shopify_api 4.8.0 → 4.9.0
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/README.md +2 -2
- data/lib/shopify_api/resources/discount_code.rb +9 -0
- data/lib/shopify_api/resources/price_rule.rb +8 -0
- data/lib/shopify_api/version.rb +1 -1
- data/test/discount_code_test.rb +53 -0
- data/test/fixtures/discount_code.json +10 -0
- data/test/fixtures/discount_codes.json +12 -0
- data/test/fixtures/price_rule.json +27 -0
- data/test/fixtures/price_rules.json +28 -0
- data/test/price_rule_test.rb +65 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fff80db1065be0d32a1762d81992769fc9cde8b6
|
4
|
+
data.tar.gz: 2a00b35496dcffdb72d0788c5b4bd18b90bee947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d53f0ae3e229f88800e277b83c4434228b1118f39627794b62868b37a4236deb626c295ee01557e10867b7070dd227a0fc1d1429201ecff203aabb2cb80ae24
|
7
|
+
data.tar.gz: 259547ebef03ae4f739ea2e7489ce0f01b8d03726037d8648c69321d8f640847872ee7b8ca27ed6c0c27ff7e4f529a04fdf35947a7b7a927a06aa05d9be5fa37
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -59,7 +59,7 @@ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveR
|
|
59
59
|
2. For a private App you just need to set the base site url as follows:
|
60
60
|
|
61
61
|
```ruby
|
62
|
-
shop_url = "https://#{API_KEY}:#{PASSWORD}
|
62
|
+
shop_url = "https://#{API_KEY}:#{PASSWORD}@#{SHOP_NAME}.myshopify.com/admin"
|
63
63
|
ShopifyAPI::Base.site = shop_url
|
64
64
|
```
|
65
65
|
|
@@ -246,7 +246,7 @@ rake install
|
|
246
246
|
|
247
247
|
## Additional Resources
|
248
248
|
|
249
|
-
API Docs:
|
249
|
+
API Docs: https://help.shopify.com/api/reference
|
250
250
|
|
251
251
|
Ask questions on the forums: http://ecommerce.shopify.com/c/shopify-apis-and-technology
|
252
252
|
|
data/lib/shopify_api/version.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DiscountCodeTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
fake 'price_rules/102586120/discount_codes/1002091923', body: load_fixture('discount_code')
|
7
|
+
|
8
|
+
@discount_code = ShopifyAPI::DiscountCode.find(1002091923, params: {price_rule_id: 102586120})
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_get_discount_code
|
12
|
+
fake 'price_rules/102586120/discount_codes', method: :get, status: 200, body: load_fixture('discount_code')
|
13
|
+
discount_code = ShopifyAPI::DiscountCode.find 1002091923, params: { price_rule_id: 102586120 }
|
14
|
+
|
15
|
+
assert_equal 1002091923, discount_code.id
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_all_discount_codes
|
19
|
+
fake 'price_rules/102586120/discount_codes', method: :get, status: 200, body: load_fixture('discount_codes')
|
20
|
+
discount_codes = ShopifyAPI::DiscountCode.all params: { price_rule_id: 102586120 }
|
21
|
+
|
22
|
+
assert_equal 1, discount_codes.length
|
23
|
+
assert_equal 1002091923, discount_codes.first.id
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create_discount_code
|
27
|
+
fake 'price_rules/102586120/discount_codes', method: :post, status: 201, body: load_fixture('discount_code')
|
28
|
+
discount_code = ShopifyAPI::DiscountCode.new
|
29
|
+
discount_code.prefix_options[:price_rule_id] = 102586120
|
30
|
+
discount_code.code = "SUMMERSALE10"
|
31
|
+
discount_code.save
|
32
|
+
|
33
|
+
assert_equal '{"discount_code":{"code":"SUMMERSALE10"}}', FakeWeb.last_request.body
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_update_discount_code
|
37
|
+
discount_code_response = ActiveSupport::JSON.decode(load_fixture('discount_code'))
|
38
|
+
discount_code_response['discount_code']['code'] = "WINTERSALE50"
|
39
|
+
@discount_code.code = "WINTERSALE50"
|
40
|
+
|
41
|
+
fake 'price_rules/102586120/discount_codes/1002091923', method: :put, status: 200, body: ActiveSupport::JSON.encode(discount_code_response)
|
42
|
+
|
43
|
+
@discount_code.save
|
44
|
+
|
45
|
+
assert_equal discount_code_response['discount_code']['code'], @discount_code.code
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_delete_discount_code
|
49
|
+
fake 'price_rules/102586120/discount_codes/1002091923', method: :delete, body: 'destroyed'
|
50
|
+
|
51
|
+
assert @discount_code.destroy
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"price_rule": {
|
3
|
+
"id": 102586120,
|
4
|
+
"target_type": "line_item",
|
5
|
+
"target_selection": "entitled",
|
6
|
+
"allocation_method": "across",
|
7
|
+
"value_type": "fixed_amount",
|
8
|
+
"value": -10.0,
|
9
|
+
"customer_selection": "all",
|
10
|
+
"once_per_customer": false,
|
11
|
+
"usage_limit": 10,
|
12
|
+
"created_at": "2016-09-11T09:00:00-04:00",
|
13
|
+
"updated_at": "2016-09-11T09:30:00-04:00",
|
14
|
+
"starts_at": "2016-09-12T0:00:00-04:00",
|
15
|
+
"ends_at": "2016-09-12T00:00:00-04:00",
|
16
|
+
"entitled_product_ids": [22,278,293],
|
17
|
+
"entitled_variant_ids": [],
|
18
|
+
"entitled_collection_ids": [],
|
19
|
+
"entitled_country_ids": [],
|
20
|
+
"prerequisite_subtotal_range": {
|
21
|
+
"greater_than_or_equal_to": 10
|
22
|
+
},
|
23
|
+
"prerequisite_shipping_price_range": {},
|
24
|
+
"prerequisite_saved_search_ids": [34,88],
|
25
|
+
"title": "Summer Sale Event 2017"
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"price_rules": [
|
3
|
+
{
|
4
|
+
"id": 102586120,
|
5
|
+
"target_type": "line_items",
|
6
|
+
"target_selection": "entitled",
|
7
|
+
"allocation_method": "each",
|
8
|
+
"value_type": "fixed_amount",
|
9
|
+
"value": -10,
|
10
|
+
"once_per_customer": false,
|
11
|
+
"usage_limit": 10,
|
12
|
+
"created_at": "2016-09-11T09:00:00-04:00",
|
13
|
+
"updated_at": "2016-09-11T09:30:00-04:00",
|
14
|
+
"starts_at": "2016-09-12T0:00:00-04:00",
|
15
|
+
"ends_at": "2016-09-12T00:00:00-04:00",
|
16
|
+
"entitled_product_ids": [22,278,293],
|
17
|
+
"entitled_variant_ids": [],
|
18
|
+
"entitled_collection_ids": [],
|
19
|
+
"entitled_country_ids": [],
|
20
|
+
"prerequisite_subtotal_range": {
|
21
|
+
"greater_than_or_equal_to": 10
|
22
|
+
},
|
23
|
+
"prerequisite_shipping_price_range": {},
|
24
|
+
"prerequisite_saved_search_ids": [34,88],
|
25
|
+
"title": "Summer Sale Event 2017"
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PriceRuleTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
fake 'price_rules/102586120', body: load_fixture('price_rule')
|
7
|
+
|
8
|
+
@price_rule = ShopifyAPI::PriceRule.find(102586120)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_get_price_rule
|
12
|
+
fake 'price_rules/102586120', method: :get, status: 200, body: load_fixture('price_rule')
|
13
|
+
price_rule = ShopifyAPI::PriceRule.find(102586120)
|
14
|
+
|
15
|
+
assert_equal 102586120, price_rule.id
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_all_price_rules
|
19
|
+
fake 'price_rules', method: :get, status: 200, body: load_fixture('price_rules')
|
20
|
+
price_rules = ShopifyAPI::PriceRule.all
|
21
|
+
|
22
|
+
assert_equal 1, price_rules.length
|
23
|
+
assert_equal 102586120, price_rules.first.id
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_get_all_discount_codes_for_a_price_rule
|
27
|
+
fake 'price_rules/102586120/discount_codes', method: :get, status: 200, body: load_fixture('discount_codes')
|
28
|
+
price_rule = ShopifyAPI::PriceRule.find(102586120)
|
29
|
+
|
30
|
+
assert_equal "SUMMERSALE10", price_rule.discount_codes.first.code
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_create_price_rule
|
34
|
+
fake 'price_rules', method: :post, status: 201, body: load_fixture('price_rule')
|
35
|
+
|
36
|
+
price_rule = ShopifyAPI::PriceRule.create(
|
37
|
+
target_type: "line_item",
|
38
|
+
allocation_method: "across",
|
39
|
+
value_type: "fixed_amount",
|
40
|
+
value: -10.0,
|
41
|
+
customer_selection: "all",
|
42
|
+
starts_at: "2017-01-19T00:00:00Z"
|
43
|
+
)
|
44
|
+
|
45
|
+
assert_equal '{"price_rule":{"target_type":"line_item","allocation_method":"across","value_type":"fixed_amount","value":-10.0,"customer_selection":"all","starts_at":"2017-01-19T00:00:00Z"}}', FakeWeb.last_request.body
|
46
|
+
assert_equal -10, price_rule.value
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_update_price_rule
|
50
|
+
price_rule_response = ActiveSupport::JSON.decode(load_fixture('price_rule'))
|
51
|
+
price_rule_response['price_rule']['value'] = -50.0
|
52
|
+
@price_rule.value = -50.0
|
53
|
+
fake 'price_rules/102586120', method: :put, status: 200, body: ActiveSupport::JSON.encode(price_rule_response)
|
54
|
+
|
55
|
+
@price_rule.save
|
56
|
+
|
57
|
+
assert_equal price_rule_response['price_rule']['value'], @price_rule.value
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_delete_price_rule
|
61
|
+
fake 'price_rules/102586120', method: :delete, body: 'destroyed'
|
62
|
+
|
63
|
+
assert @price_rule.destroy
|
64
|
+
end
|
65
|
+
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.
|
4
|
+
version: 4.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/shopify_api/resources/customer_invite_message.rb
|
175
175
|
- lib/shopify_api/resources/customer_saved_search.rb
|
176
176
|
- lib/shopify_api/resources/discount.rb
|
177
|
+
- lib/shopify_api/resources/discount_code.rb
|
177
178
|
- lib/shopify_api/resources/draft_order.rb
|
178
179
|
- lib/shopify_api/resources/draft_order_invoice.rb
|
179
180
|
- lib/shopify_api/resources/event.rb
|
@@ -195,6 +196,7 @@ files:
|
|
195
196
|
- lib/shopify_api/resources/page.rb
|
196
197
|
- lib/shopify_api/resources/payment_details.rb
|
197
198
|
- lib/shopify_api/resources/policy.rb
|
199
|
+
- lib/shopify_api/resources/price_rule.rb
|
198
200
|
- lib/shopify_api/resources/product.rb
|
199
201
|
- lib/shopify_api/resources/product_listing.rb
|
200
202
|
- lib/shopify_api/resources/province.rb
|
@@ -242,6 +244,7 @@ files:
|
|
242
244
|
- test/customer_saved_search_test.rb
|
243
245
|
- test/customer_test.rb
|
244
246
|
- test/detailed_log_subscriber_test.rb
|
247
|
+
- test/discount_code_test.rb
|
245
248
|
- test/discount_test.rb
|
246
249
|
- test/draft_order_test.rb
|
247
250
|
- test/fixtures/access_token_delegate.json
|
@@ -271,6 +274,8 @@ files:
|
|
271
274
|
- test/fixtures/customers_account_activation_url.json
|
272
275
|
- test/fixtures/customers_search.json
|
273
276
|
- test/fixtures/discount.json
|
277
|
+
- test/fixtures/discount_code.json
|
278
|
+
- test/fixtures/discount_codes.json
|
274
279
|
- test/fixtures/discount_disabled.json
|
275
280
|
- test/fixtures/discounts.json
|
276
281
|
- test/fixtures/draft_order.json
|
@@ -297,6 +302,8 @@ files:
|
|
297
302
|
- test/fixtures/order_risks.json
|
298
303
|
- test/fixtures/orders.json
|
299
304
|
- test/fixtures/policies.json
|
305
|
+
- test/fixtures/price_rule.json
|
306
|
+
- test/fixtures/price_rules.json
|
300
307
|
- test/fixtures/product.json
|
301
308
|
- test/fixtures/product_listing.json
|
302
309
|
- test/fixtures/product_listing_product_ids.json
|
@@ -339,6 +346,7 @@ files:
|
|
339
346
|
- test/order_risk_test.rb
|
340
347
|
- test/order_test.rb
|
341
348
|
- test/policy_test.rb
|
349
|
+
- test/price_rule_test.rb
|
342
350
|
- test/product_listing_test.rb
|
343
351
|
- test/product_test.rb
|
344
352
|
- test/recurring_application_charge_test.rb
|