shopify_api 9.0.4 → 9.5
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/.github/CODEOWNERS +1 -1
- data/.github/ISSUE_TEMPLATE.md +36 -0
- data/.github/workflows/build.yml +44 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +23 -3
- data/.rubocop_todo.yml +75 -0
- data/CHANGELOG.md +41 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +5 -0
- data/Gemfile.lock +153 -0
- data/Gemfile_ar51 +1 -1
- data/README.md +42 -32
- data/RELEASING +10 -6
- data/Rakefile +16 -5
- data/SECURITY.md +59 -0
- data/dev.yml +11 -0
- data/docs/_config.yml +1 -0
- data/docs/_includes/footer.html +28 -0
- data/docs/_includes/head.html +28 -0
- data/docs/_layouts/index.html +57 -0
- data/docs/graphql.md +47 -2
- data/docs/index.md +639 -0
- data/lib/active_resource/connection_ext.rb +1 -0
- data/lib/active_resource/detailed_log_subscriber.rb +10 -7
- data/lib/active_resource/json_errors.rb +8 -2
- data/lib/shopify_api/api_access.rb +57 -0
- data/lib/shopify_api/api_version.rb +6 -5
- data/lib/shopify_api/connection.rb +1 -0
- data/lib/shopify_api/countable.rb +3 -2
- data/lib/shopify_api/disable_prefix_check.rb +2 -2
- data/lib/shopify_api/events.rb +2 -1
- data/lib/shopify_api/graphql.rb +28 -8
- data/lib/shopify_api/hmac_params.rb +23 -0
- data/lib/shopify_api/limits.rb +3 -2
- data/lib/shopify_api/message_enricher.rb +11 -9
- data/lib/shopify_api/meta.rb +0 -1
- data/lib/shopify_api/metafields.rb +5 -4
- data/lib/shopify_api/pagination_link_headers.rb +5 -4
- data/lib/shopify_api/resources/access_scope.rb +1 -1
- data/lib/shopify_api/resources/access_token.rb +1 -0
- data/lib/shopify_api/resources/address.rb +1 -0
- data/lib/shopify_api/resources/announcement.rb +2 -1
- data/lib/shopify_api/resources/application_charge.rb +1 -0
- data/lib/shopify_api/resources/application_credit.rb +1 -0
- data/lib/shopify_api/resources/article.rb +3 -2
- data/lib/shopify_api/resources/asset.rb +6 -5
- data/lib/shopify_api/resources/assigned_fulfillment_order.rb +1 -1
- data/lib/shopify_api/resources/base.rb +12 -8
- data/lib/shopify_api/resources/billing_address.rb +1 -0
- data/lib/shopify_api/resources/blog.rb +2 -1
- data/lib/shopify_api/resources/carrier_service.rb +1 -0
- data/lib/shopify_api/resources/cart.rb +2 -1
- data/lib/shopify_api/resources/collect.rb +1 -0
- data/lib/shopify_api/resources/collection_listing.rb +1 -0
- data/lib/shopify_api/resources/comment.rb +20 -5
- data/lib/shopify_api/resources/country.rb +1 -0
- data/lib/shopify_api/resources/custom_collection.rb +4 -3
- data/lib/shopify_api/resources/customer.rb +2 -1
- data/lib/shopify_api/resources/customer_group.rb +1 -0
- data/lib/shopify_api/resources/customer_invite.rb +1 -0
- data/lib/shopify_api/resources/customer_saved_search.rb +2 -1
- data/lib/shopify_api/resources/discount_code.rb +1 -0
- data/lib/shopify_api/resources/discount_code_batch.rb +4 -2
- data/lib/shopify_api/resources/draft_order.rb +1 -0
- data/lib/shopify_api/resources/draft_order_invoice.rb +1 -0
- data/lib/shopify_api/resources/event.rb +1 -0
- data/lib/shopify_api/resources/fulfillment.rb +12 -3
- data/lib/shopify_api/resources/fulfillment_event.rb +1 -0
- data/lib/shopify_api/resources/fulfillment_order.rb +30 -16
- data/lib/shopify_api/resources/fulfillment_order_locations_for_move.rb +1 -0
- data/lib/shopify_api/resources/fulfillment_request.rb +1 -0
- data/lib/shopify_api/resources/fulfillment_service.rb +1 -0
- data/lib/shopify_api/resources/fulfillment_v2.rb +3 -2
- data/lib/shopify_api/resources/gift_card.rb +1 -0
- data/lib/shopify_api/resources/image.rb +2 -1
- data/lib/shopify_api/resources/inventory_level.rb +3 -4
- data/lib/shopify_api/resources/line_item.rb +4 -3
- data/lib/shopify_api/resources/location.rb +1 -1
- data/lib/shopify_api/resources/marketing_event.rb +1 -0
- data/lib/shopify_api/resources/metafield.rb +1 -0
- data/lib/shopify_api/resources/note_attribute.rb +1 -0
- data/lib/shopify_api/resources/option.rb +1 -0
- data/lib/shopify_api/resources/order.rb +2 -1
- data/lib/shopify_api/resources/order_risk.rb +1 -0
- data/lib/shopify_api/resources/page.rb +1 -0
- data/lib/shopify_api/resources/payment_details.rb +1 -0
- data/lib/shopify_api/resources/policy.rb +1 -0
- data/lib/shopify_api/resources/price_rule.rb +1 -1
- data/lib/shopify_api/resources/product.rb +27 -3
- data/lib/shopify_api/resources/product_listing.rb +1 -0
- data/lib/shopify_api/resources/province.rb +1 -0
- data/lib/shopify_api/resources/receipt.rb +1 -0
- data/lib/shopify_api/resources/recurring_application_charge.rb +4 -1
- data/lib/shopify_api/resources/redirect.rb +1 -0
- data/lib/shopify_api/resources/refund.rb +2 -1
- data/lib/shopify_api/resources/report.rb +1 -0
- data/lib/shopify_api/resources/resource_feedback.rb +1 -1
- data/lib/shopify_api/resources/rule.rb +1 -0
- data/lib/shopify_api/resources/script_tag.rb +1 -0
- data/lib/shopify_api/resources/shipping_address.rb +1 -0
- data/lib/shopify_api/resources/shipping_line.rb +1 -0
- data/lib/shopify_api/resources/shipping_zone.rb +1 -0
- data/lib/shopify_api/resources/shop.rb +2 -1
- data/lib/shopify_api/resources/smart_collection.rb +4 -8
- data/lib/shopify_api/resources/storefront_access_token.rb +1 -0
- data/lib/shopify_api/resources/tax_line.rb +1 -0
- data/lib/shopify_api/resources/tax_service.rb +1 -0
- data/lib/shopify_api/resources/theme.rb +1 -0
- data/lib/shopify_api/resources/transaction.rb +1 -0
- data/lib/shopify_api/resources/usage_charge.rb +1 -0
- data/lib/shopify_api/resources/user.rb +1 -0
- data/lib/shopify_api/resources/variant.rb +35 -0
- data/lib/shopify_api/resources/webhook.rb +1 -0
- data/lib/shopify_api/resources.rb +1 -0
- data/lib/shopify_api/session.rb +51 -20
- data/lib/shopify_api/version.rb +2 -1
- data/lib/shopify_api.rb +9 -1
- data/lib/verify_docs.rb +8 -0
- data/service.yml +2 -5
- data/shopify_api.gemspec +13 -7
- data/test/access_token_test.rb +6 -5
- data/test/active_resource/json_errors_test.rb +6 -6
- data/test/api_access_test.rb +153 -0
- data/test/api_version_test.rb +3 -3
- data/test/application_charge_test.rb +30 -27
- data/test/application_credit_test.rb +10 -9
- data/test/article_test.rb +34 -35
- data/test/asset_test.rb +14 -6
- data/test/assigned_fulfillment_order_test.rb +5 -4
- data/test/base_test.rb +64 -49
- data/test/blog_test.rb +4 -3
- data/test/carrier_service_test.rb +7 -6
- data/test/cart_test.rb +2 -1
- data/test/collect_test.rb +4 -3
- data/test/collection_listing_test.rb +21 -16
- data/test/collection_publication_test.rb +8 -8
- data/test/collection_test.rb +20 -19
- data/test/countable_test.rb +3 -2
- data/test/currency_test.rb +5 -5
- data/test/custom_collection_test.rb +4 -3
- data/test/customer_saved_search_test.rb +18 -8
- data/test/customer_test.rb +22 -14
- data/test/detailed_log_subscriber_test.rb +16 -12
- data/test/discount_code_batch_test.rb +11 -10
- data/test/discount_code_test.rb +21 -15
- data/test/draft_order_test.rb +68 -52
- data/test/fixtures/assigned_fulfillment_orders.json +2 -0
- data/test/fixtures/fulfillment_order.json +1 -0
- data/test/fixtures/fulfillment_orders.json +2 -0
- data/test/fulfillment_event_test.rb +31 -26
- data/test/fulfillment_order_test.rb +217 -149
- data/test/fulfillment_order_test_helper.rb +1 -0
- data/test/fulfillment_request_test.rb +10 -8
- data/test/fulfillment_service_test.rb +13 -12
- data/test/fulfillment_test.rb +81 -66
- data/test/fulfillment_v2_test.rb +16 -12
- data/test/gift_card_test.rb +6 -4
- data/test/graphql_test.rb +55 -23
- data/test/hmac_params_test.rb +25 -0
- data/test/image_test.rb +19 -17
- data/test/inventory_level_test.rb +24 -15
- data/test/lib/webmock_extensions/last_request.rb +1 -1
- data/test/limits_test.rb +2 -1
- data/test/location_test.rb +2 -1
- data/test/marketing_event_test.rb +20 -20
- data/test/message_enricher_test.rb +6 -6
- data/test/meta_test.rb +9 -11
- data/test/metafield_test.rb +30 -20
- data/test/order_risk_test.rb +17 -16
- data/test/order_test.rb +43 -28
- data/test/pagination_test.rb +89 -56
- data/test/policy_test.rb +6 -5
- data/test/price_rule_test.rb +20 -15
- data/test/product_listing_test.rb +20 -20
- data/test/product_publication_test.rb +8 -8
- data/test/product_test.rb +71 -20
- data/test/publication_test.rb +3 -3
- data/test/recurring_application_charge_test.rb +104 -42
- data/test/redirect_test.rb +4 -3
- data/test/refund_test.rb +22 -17
- data/test/report_test.rb +12 -10
- data/test/resource_feedback_test.rb +14 -13
- data/test/script_tag_test.rb +10 -9
- data/test/session_test.rb +319 -45
- data/test/shipping_zone_test.rb +4 -3
- data/test/shop_test.rb +47 -33
- data/test/smart_collection_test.rb +5 -29
- data/test/storefront_access_token_test.rb +13 -15
- data/test/tax_service_test.rb +7 -4
- data/test/tender_transaction_test.rb +3 -3
- data/test/test_helper.rb +14 -12
- data/test/transaction_test.rb +4 -3
- data/test/usage_charge_test.rb +12 -8
- data/test/user_test.rb +4 -3
- data/test/variant_test.rb +50 -23
- data/test/webhook_test.rb +10 -7
- metadata +44 -17
- data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +0 -1027
- data/.travis.yml +0 -23
- data/bin/shopify +0 -3
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class CustomCollection < Base
|
|
3
4
|
include Events
|
|
4
5
|
include Metafields
|
|
5
6
|
|
|
6
7
|
def products
|
|
7
|
-
Product.find(:all, :
|
|
8
|
+
Product.find(:all, params: { collection_id: self.id })
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
def add_product(product)
|
|
11
|
-
Collect.create(:
|
|
12
|
+
Collect.create(collection_id: self.id, product_id: product.id)
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def remove_product(product)
|
|
15
|
-
collect = Collect.find(:first, :
|
|
16
|
+
collect = Collect.find(:first, params: { collection_id: self.id, product_id: product.id })
|
|
16
17
|
collect.destroy if collect
|
|
17
18
|
end
|
|
18
19
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'shopify_api/resources/customer'
|
|
2
3
|
|
|
3
4
|
module ShopifyAPI
|
|
@@ -5,7 +6,7 @@ module ShopifyAPI
|
|
|
5
6
|
early_july_pagination_release!
|
|
6
7
|
|
|
7
8
|
def customers(params = {})
|
|
8
|
-
Customer.search(params.merge({:
|
|
9
|
+
Customer.search(params.merge({ customer_saved_search_id: self.id }))
|
|
9
10
|
end
|
|
10
11
|
end
|
|
11
12
|
end
|
|
@@ -12,8 +12,10 @@ module ShopifyAPI
|
|
|
12
12
|
def discount_code_job
|
|
13
13
|
@discount_codes ||= begin
|
|
14
14
|
if id
|
|
15
|
-
path = self.class.api_version.construct_api_path(
|
|
16
|
-
|
|
15
|
+
path = self.class.api_version.construct_api_path(
|
|
16
|
+
"price_rules/#{price_rule_id}/batch/#{id}/discount_codes.json"
|
|
17
|
+
)
|
|
18
|
+
discount_codes = ShopifyAPI::DiscountCode.find(:all, from: path)
|
|
17
19
|
discount_codes.each do |code|
|
|
18
20
|
errors = code.attributes['errors']
|
|
19
21
|
errors.attributes.each do |key, values|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class Fulfillment < Base
|
|
3
4
|
init_prefix :order
|
|
@@ -6,9 +7,17 @@ module ShopifyAPI
|
|
|
6
7
|
@prefix_options[:order_id]
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
def cancel
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
def cancel
|
|
11
|
+
load_attributes_from_response(post(:cancel, {}, only_id))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def complete
|
|
15
|
+
load_attributes_from_response(post(:complete, {}, only_id))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def open
|
|
19
|
+
load_attributes_from_response(post(:open, {}, only_id))
|
|
20
|
+
end
|
|
12
21
|
|
|
13
22
|
def order_id=(order_id)
|
|
14
23
|
prefix_options[:order_id] = order_id
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class FulfillmentOrder < Base
|
|
3
4
|
MINIMUM_VERSION = '2020-01'
|
|
@@ -37,8 +38,8 @@ module ShopifyAPI
|
|
|
37
38
|
def move(new_location_id:)
|
|
38
39
|
body = {
|
|
39
40
|
fulfillment_order: {
|
|
40
|
-
new_location_id: new_location_id
|
|
41
|
-
}
|
|
41
|
+
new_location_id: new_location_id,
|
|
42
|
+
},
|
|
42
43
|
}
|
|
43
44
|
keyed_fulfillment_orders = keyed_fulfillment_orders_from_response(post(:move, {}, body.to_json))
|
|
44
45
|
load_keyed_fulfillment_order(keyed_fulfillment_orders, 'original_fulfillment_order')
|
|
@@ -51,11 +52,24 @@ module ShopifyAPI
|
|
|
51
52
|
keyed_fulfillment_orders
|
|
52
53
|
end
|
|
53
54
|
|
|
55
|
+
def open
|
|
56
|
+
load_attributes_from_response(post(:open, {}, only_id))
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def reschedule(new_fulfill_at:)
|
|
60
|
+
body = {
|
|
61
|
+
fulfillment_order: {
|
|
62
|
+
new_fulfill_at: new_fulfill_at,
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
load_attributes_from_response(post(:reschedule, {}, body.to_json))
|
|
66
|
+
end
|
|
67
|
+
|
|
54
68
|
def close(message: nil)
|
|
55
69
|
body = {
|
|
56
70
|
fulfillment_order: {
|
|
57
|
-
message: message
|
|
58
|
-
}
|
|
71
|
+
message: message,
|
|
72
|
+
},
|
|
59
73
|
}
|
|
60
74
|
load_attributes_from_response(post(:close, {}, body.to_json))
|
|
61
75
|
end
|
|
@@ -64,8 +78,8 @@ module ShopifyAPI
|
|
|
64
78
|
body = {
|
|
65
79
|
fulfillment_request: {
|
|
66
80
|
fulfillment_order_line_items: fulfillment_order_line_items,
|
|
67
|
-
message: message
|
|
68
|
-
}
|
|
81
|
+
message: message,
|
|
82
|
+
},
|
|
69
83
|
}
|
|
70
84
|
keyed_fulfillment_orders = keyed_fulfillment_orders_from_response(post(:fulfillment_request, {}, body.to_json))
|
|
71
85
|
load_keyed_fulfillment_order(keyed_fulfillment_orders, 'original_fulfillment_order')
|
|
@@ -75,8 +89,8 @@ module ShopifyAPI
|
|
|
75
89
|
def accept_fulfillment_request(message: nil)
|
|
76
90
|
body = {
|
|
77
91
|
fulfillment_request: {
|
|
78
|
-
message: message
|
|
79
|
-
}
|
|
92
|
+
message: message,
|
|
93
|
+
},
|
|
80
94
|
}
|
|
81
95
|
load_attributes_from_response(post('fulfillment_request/accept', {}, body.to_json))
|
|
82
96
|
end
|
|
@@ -84,8 +98,8 @@ module ShopifyAPI
|
|
|
84
98
|
def reject_fulfillment_request(message: nil)
|
|
85
99
|
body = {
|
|
86
100
|
fulfillment_request: {
|
|
87
|
-
message: message
|
|
88
|
-
}
|
|
101
|
+
message: message,
|
|
102
|
+
},
|
|
89
103
|
}
|
|
90
104
|
load_attributes_from_response(post('fulfillment_request/reject', {}, body.to_json))
|
|
91
105
|
end
|
|
@@ -93,8 +107,8 @@ module ShopifyAPI
|
|
|
93
107
|
def request_cancellation(message: nil)
|
|
94
108
|
body = {
|
|
95
109
|
cancellation_request: {
|
|
96
|
-
message: message
|
|
97
|
-
}
|
|
110
|
+
message: message,
|
|
111
|
+
},
|
|
98
112
|
}
|
|
99
113
|
load_attributes_from_response(post(:cancellation_request, {}, body.to_json))
|
|
100
114
|
end
|
|
@@ -102,8 +116,8 @@ module ShopifyAPI
|
|
|
102
116
|
def accept_cancellation_request(message: nil)
|
|
103
117
|
body = {
|
|
104
118
|
cancellation_request: {
|
|
105
|
-
message: message
|
|
106
|
-
}
|
|
119
|
+
message: message,
|
|
120
|
+
},
|
|
107
121
|
}
|
|
108
122
|
load_attributes_from_response(post('cancellation_request/accept', {}, body.to_json))
|
|
109
123
|
end
|
|
@@ -111,8 +125,8 @@ module ShopifyAPI
|
|
|
111
125
|
def reject_cancellation_request(message: nil)
|
|
112
126
|
body = {
|
|
113
127
|
cancellation_request: {
|
|
114
|
-
message: message
|
|
115
|
-
}
|
|
128
|
+
message: message,
|
|
129
|
+
},
|
|
116
130
|
}
|
|
117
131
|
load_attributes_from_response(post('cancellation_request/reject', {}, body.to_json))
|
|
118
132
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class FulfillmentV2 < Base
|
|
3
4
|
self.element_name = 'fulfillment'
|
|
@@ -11,8 +12,8 @@ module ShopifyAPI
|
|
|
11
12
|
body = {
|
|
12
13
|
fulfillment: {
|
|
13
14
|
tracking_info: tracking_info,
|
|
14
|
-
notify_customer: notify_customer
|
|
15
|
-
}
|
|
15
|
+
notify_customer: notify_customer,
|
|
16
|
+
},
|
|
16
17
|
}
|
|
17
18
|
load_attributes_from_response(post(:update_tracking, {}, body.to_json))
|
|
18
19
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class Image < Base
|
|
3
4
|
init_prefix :product
|
|
@@ -5,7 +6,7 @@ module ShopifyAPI
|
|
|
5
6
|
# generate a method for each possible image variant
|
|
6
7
|
[:pico, :icon, :thumb, :small, :compact, :medium, :large, :grande, :original].each do |m|
|
|
7
8
|
reg_exp_match = "/\\1_#{m}.\\2"
|
|
8
|
-
define_method(m) { src.gsub(/\/(.*)\.(\w{2,4})/, reg_exp_match) }
|
|
9
|
+
define_method(m) { src.gsub(%r/\/(.*)\.(\w{2,4})/, reg_exp_match) }
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def attach_image(data, filename = nil)
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module ShopifyAPI
|
|
4
4
|
class InventoryLevel < Base
|
|
5
|
-
|
|
6
5
|
# The default path structure in ActiveResource for delete would result in:
|
|
7
6
|
# /admin/api/<version>/inventory_levels/#{ inventory_level.id }.json?#{ params }, but since
|
|
8
|
-
#
|
|
7
|
+
# InventoryLevels are a second class resource made up of a Where and a What
|
|
9
8
|
# (Location and InventoryItem), it does not have a resource ID. Here we
|
|
10
9
|
# redefine element_path to remove the id so HTTP DELETE requests go to
|
|
11
10
|
# /admin/api/<version>/inventory_levels.json?#{ params } instead.
|
|
@@ -33,7 +32,7 @@ module ShopifyAPI
|
|
|
33
32
|
body = {
|
|
34
33
|
location_id: location_id,
|
|
35
34
|
inventory_item_id: inventory_item_id,
|
|
36
|
-
available: new_available
|
|
35
|
+
available: new_available,
|
|
37
36
|
}
|
|
38
37
|
body[:disconnect_if_necessary] = disconnect_if_necessary unless disconnect_if_necessary.nil?
|
|
39
38
|
load_attributes_from_response(
|
|
@@ -45,7 +44,7 @@ module ShopifyAPI
|
|
|
45
44
|
body = {
|
|
46
45
|
location_id: location_id,
|
|
47
46
|
inventory_item_id: inventory_item_id,
|
|
48
|
-
available_adjustment: available_adjustment
|
|
47
|
+
available_adjustment: available_adjustment,
|
|
49
48
|
}
|
|
50
49
|
load_attributes_from_response(
|
|
51
50
|
self.class.post(:adjust, {}, body.to_json)
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class LineItem < Base
|
|
3
4
|
class Property < Base
|
|
4
5
|
def initialize(*args)
|
|
5
|
-
attributes = args[0] || {}
|
|
6
|
-
persisted = args[1] || false
|
|
6
|
+
self.attributes = args[0] || {}
|
|
7
|
+
self.persisted = args[1] || false
|
|
7
8
|
super
|
|
8
9
|
rescue NameError
|
|
9
|
-
attributes = attributes.to_hash
|
|
10
|
+
self.attributes = attributes.to_hash
|
|
10
11
|
self
|
|
11
12
|
end
|
|
12
13
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class Order < Base
|
|
3
4
|
include Events
|
|
@@ -16,7 +17,7 @@ module ShopifyAPI
|
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def transactions
|
|
19
|
-
Transaction.find(:all, :
|
|
20
|
+
Transaction.find(:all, params: { order_id: id })
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
def capture(amount = "", currency: nil)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class Product < Base
|
|
3
4
|
include Events
|
|
@@ -5,10 +6,15 @@ module ShopifyAPI
|
|
|
5
6
|
|
|
6
7
|
early_july_pagination_release!
|
|
7
8
|
|
|
9
|
+
def initialize(*)
|
|
10
|
+
super
|
|
11
|
+
self.attributes.except!('total_inventory') unless allow_inventory_params?
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
# compute the price range
|
|
9
15
|
def price_range
|
|
10
16
|
prices = variants.collect(&:price).collect(&:to_f)
|
|
11
|
-
format =
|
|
17
|
+
format = "%0.2f"
|
|
12
18
|
if prices.min != prices.max
|
|
13
19
|
"#{format % prices.min} - #{format % prices.max}"
|
|
14
20
|
else
|
|
@@ -16,12 +22,17 @@ module ShopifyAPI
|
|
|
16
22
|
end
|
|
17
23
|
end
|
|
18
24
|
|
|
25
|
+
def total_inventory=(new_value)
|
|
26
|
+
raise_deprecated_inventory_call('total_inventory') unless allow_inventory_params?
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
|
|
19
30
|
def collections
|
|
20
|
-
CustomCollection.find(:all, :
|
|
31
|
+
CustomCollection.find(:all, params: { product_id: self.id })
|
|
21
32
|
end
|
|
22
33
|
|
|
23
34
|
def smart_collections
|
|
24
|
-
SmartCollection.find(:all, :
|
|
35
|
+
SmartCollection.find(:all, params: { product_id: self.id })
|
|
25
36
|
end
|
|
26
37
|
|
|
27
38
|
def add_to_collection(collection)
|
|
@@ -31,5 +42,18 @@ module ShopifyAPI
|
|
|
31
42
|
def remove_from_collection(collection)
|
|
32
43
|
collection.remove_product(self)
|
|
33
44
|
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def raise_deprecated_inventory_call(parameter)
|
|
49
|
+
raise(
|
|
50
|
+
ShopifyAPI::ValidationException,
|
|
51
|
+
"'#{parameter}' is deprecated - see https://help.shopify.com/en/api/guides/inventory-migration-guide",
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def allow_inventory_params?
|
|
56
|
+
Base.api_version < ApiVersion.find_version('2019-10')
|
|
57
|
+
end
|
|
34
58
|
end
|
|
35
59
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class RecurringApplicationCharge < Base
|
|
3
4
|
undef_method :test
|
|
@@ -25,7 +26,9 @@ module ShopifyAPI
|
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
def customize(customize_recurring_app_charge_params = {})
|
|
28
|
-
load_attributes_from_response(
|
|
29
|
+
load_attributes_from_response(
|
|
30
|
+
put(:customize, recurring_application_charge: customize_recurring_app_charge_params)
|
|
31
|
+
)
|
|
29
32
|
end
|
|
30
33
|
end
|
|
31
34
|
end
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class Refund < Base
|
|
3
4
|
init_prefix :order
|
|
4
5
|
|
|
5
6
|
def self.calculate(*args)
|
|
6
|
-
options = { :
|
|
7
|
+
options = { refund: args[0] }
|
|
7
8
|
params = {}
|
|
8
9
|
params = args[1][:params] if args[1] && args[1][:params]
|
|
9
10
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
# Shop object. Use Shop.current to receive
|
|
3
4
|
# the shop.
|
|
@@ -9,7 +10,7 @@ module ShopifyAPI
|
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def metafields(**options)
|
|
12
|
-
Metafield.find
|
|
13
|
+
Metafield.find(:all, params: options)
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def add_metafield(metafield)
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ShopifyAPI
|
|
2
3
|
class SmartCollection < Base
|
|
3
4
|
include Events
|
|
4
5
|
include Metafields
|
|
5
6
|
|
|
6
|
-
def products
|
|
7
|
-
|
|
8
|
-
Product.find(:all, from: "#{self.class.prefix}smart_collections/#{id}/products.json", params: options)
|
|
9
|
-
else
|
|
10
|
-
Product.find(:all, params: { collection_id: id })
|
|
11
|
-
end
|
|
7
|
+
def products
|
|
8
|
+
Product.find(:all, params: { collection_id: id })
|
|
12
9
|
end
|
|
13
10
|
|
|
14
|
-
def order(options={})
|
|
11
|
+
def order(options = {})
|
|
15
12
|
load_attributes_from_response(put(:order, options, only_id))
|
|
16
13
|
end
|
|
17
|
-
|
|
18
14
|
end
|
|
19
15
|
end
|