shopify_api 9.0.2 → 9.3.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.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +36 -0
  3. data/.github/workflows/build.yml +41 -0
  4. data/.gitignore +2 -1
  5. data/.rubocop.yml +23 -3
  6. data/.rubocop_todo.yml +75 -0
  7. data/CHANGELOG.md +43 -0
  8. data/CONTRIBUTING.md +1 -1
  9. data/Gemfile +5 -0
  10. data/Gemfile.lock +151 -0
  11. data/Gemfile_ar51 +1 -1
  12. data/README.md +47 -31
  13. data/RELEASING +10 -6
  14. data/Rakefile +16 -5
  15. data/SECURITY.md +59 -0
  16. data/docs/_config.yml +1 -0
  17. data/docs/_includes/footer.html +28 -0
  18. data/docs/_includes/head.html +28 -0
  19. data/docs/_layouts/index.html +57 -0
  20. data/docs/graphql.md +47 -2
  21. data/docs/index.md +639 -0
  22. data/lib/active_resource/connection_ext.rb +1 -0
  23. data/lib/active_resource/detailed_log_subscriber.rb +6 -7
  24. data/lib/active_resource/json_errors.rb +8 -2
  25. data/lib/shopify_api.rb +8 -1
  26. data/lib/shopify_api/api_access.rb +57 -0
  27. data/lib/shopify_api/api_version.rb +6 -5
  28. data/lib/shopify_api/connection.rb +1 -0
  29. data/lib/shopify_api/countable.rb +3 -2
  30. data/lib/shopify_api/disable_prefix_check.rb +2 -2
  31. data/lib/shopify_api/events.rb +2 -1
  32. data/lib/shopify_api/graphql.rb +28 -8
  33. data/lib/shopify_api/limits.rb +3 -2
  34. data/lib/shopify_api/message_enricher.rb +11 -9
  35. data/lib/shopify_api/meta.rb +0 -1
  36. data/lib/shopify_api/metafields.rb +5 -4
  37. data/lib/shopify_api/pagination_link_headers.rb +5 -4
  38. data/lib/shopify_api/resources.rb +1 -0
  39. data/lib/shopify_api/resources/access_scope.rb +1 -1
  40. data/lib/shopify_api/resources/access_token.rb +1 -0
  41. data/lib/shopify_api/resources/address.rb +1 -0
  42. data/lib/shopify_api/resources/announcement.rb +2 -1
  43. data/lib/shopify_api/resources/application_charge.rb +1 -0
  44. data/lib/shopify_api/resources/application_credit.rb +1 -0
  45. data/lib/shopify_api/resources/article.rb +3 -2
  46. data/lib/shopify_api/resources/asset.rb +6 -5
  47. data/lib/shopify_api/resources/assigned_fulfillment_order.rb +1 -1
  48. data/lib/shopify_api/resources/base.rb +12 -8
  49. data/lib/shopify_api/resources/billing_address.rb +1 -0
  50. data/lib/shopify_api/resources/blog.rb +2 -1
  51. data/lib/shopify_api/resources/carrier_service.rb +1 -0
  52. data/lib/shopify_api/resources/cart.rb +2 -1
  53. data/lib/shopify_api/resources/collect.rb +1 -0
  54. data/lib/shopify_api/resources/collection_listing.rb +1 -0
  55. data/lib/shopify_api/resources/comment.rb +20 -5
  56. data/lib/shopify_api/resources/country.rb +1 -0
  57. data/lib/shopify_api/resources/custom_collection.rb +4 -3
  58. data/lib/shopify_api/resources/customer.rb +2 -1
  59. data/lib/shopify_api/resources/customer_group.rb +1 -0
  60. data/lib/shopify_api/resources/customer_invite.rb +1 -0
  61. data/lib/shopify_api/resources/customer_saved_search.rb +2 -1
  62. data/lib/shopify_api/resources/discount_code.rb +1 -0
  63. data/lib/shopify_api/resources/discount_code_batch.rb +34 -0
  64. data/lib/shopify_api/resources/draft_order.rb +1 -0
  65. data/lib/shopify_api/resources/draft_order_invoice.rb +1 -0
  66. data/lib/shopify_api/resources/event.rb +1 -0
  67. data/lib/shopify_api/resources/fulfillment.rb +12 -3
  68. data/lib/shopify_api/resources/fulfillment_event.rb +1 -0
  69. data/lib/shopify_api/resources/fulfillment_order.rb +30 -16
  70. data/lib/shopify_api/resources/fulfillment_order_locations_for_move.rb +1 -0
  71. data/lib/shopify_api/resources/fulfillment_request.rb +1 -0
  72. data/lib/shopify_api/resources/fulfillment_service.rb +1 -0
  73. data/lib/shopify_api/resources/fulfillment_v2.rb +3 -2
  74. data/lib/shopify_api/resources/gift_card.rb +1 -0
  75. data/lib/shopify_api/resources/image.rb +2 -1
  76. data/lib/shopify_api/resources/inventory_level.rb +3 -4
  77. data/lib/shopify_api/resources/line_item.rb +4 -3
  78. data/lib/shopify_api/resources/location.rb +1 -1
  79. data/lib/shopify_api/resources/marketing_event.rb +1 -0
  80. data/lib/shopify_api/resources/metafield.rb +1 -0
  81. data/lib/shopify_api/resources/note_attribute.rb +1 -0
  82. data/lib/shopify_api/resources/option.rb +1 -0
  83. data/lib/shopify_api/resources/order.rb +2 -1
  84. data/lib/shopify_api/resources/order_risk.rb +1 -0
  85. data/lib/shopify_api/resources/page.rb +1 -0
  86. data/lib/shopify_api/resources/payment_details.rb +1 -0
  87. data/lib/shopify_api/resources/policy.rb +1 -0
  88. data/lib/shopify_api/resources/price_rule.rb +1 -1
  89. data/lib/shopify_api/resources/product.rb +27 -3
  90. data/lib/shopify_api/resources/product_listing.rb +1 -0
  91. data/lib/shopify_api/resources/province.rb +1 -0
  92. data/lib/shopify_api/resources/receipt.rb +1 -0
  93. data/lib/shopify_api/resources/recurring_application_charge.rb +4 -1
  94. data/lib/shopify_api/resources/redirect.rb +1 -0
  95. data/lib/shopify_api/resources/refund.rb +2 -1
  96. data/lib/shopify_api/resources/report.rb +1 -0
  97. data/lib/shopify_api/resources/resource_feedback.rb +1 -1
  98. data/lib/shopify_api/resources/rule.rb +1 -0
  99. data/lib/shopify_api/resources/script_tag.rb +1 -0
  100. data/lib/shopify_api/resources/shipping_address.rb +1 -0
  101. data/lib/shopify_api/resources/shipping_line.rb +1 -0
  102. data/lib/shopify_api/resources/shipping_zone.rb +1 -0
  103. data/lib/shopify_api/resources/shop.rb +2 -1
  104. data/lib/shopify_api/resources/smart_collection.rb +4 -8
  105. data/lib/shopify_api/resources/storefront_access_token.rb +1 -0
  106. data/lib/shopify_api/resources/tax_line.rb +1 -0
  107. data/lib/shopify_api/resources/tax_service.rb +1 -0
  108. data/lib/shopify_api/resources/theme.rb +1 -0
  109. data/lib/shopify_api/resources/transaction.rb +1 -0
  110. data/lib/shopify_api/resources/usage_charge.rb +1 -0
  111. data/lib/shopify_api/resources/user.rb +1 -0
  112. data/lib/shopify_api/resources/variant.rb +35 -0
  113. data/lib/shopify_api/resources/webhook.rb +1 -0
  114. data/lib/shopify_api/session.rb +43 -14
  115. data/lib/shopify_api/version.rb +2 -1
  116. data/lib/verify_docs.rb +8 -0
  117. data/service.yml +1 -1
  118. data/shopify_api.gemspec +13 -6
  119. data/test/access_token_test.rb +6 -5
  120. data/test/active_resource/json_errors_test.rb +6 -6
  121. data/test/api_access_test.rb +153 -0
  122. data/test/api_version_test.rb +3 -3
  123. data/test/application_charge_test.rb +30 -27
  124. data/test/application_credit_test.rb +10 -9
  125. data/test/article_test.rb +34 -35
  126. data/test/asset_test.rb +14 -6
  127. data/test/assigned_fulfillment_order_test.rb +5 -4
  128. data/test/base_test.rb +64 -49
  129. data/test/blog_test.rb +4 -3
  130. data/test/carrier_service_test.rb +7 -6
  131. data/test/cart_test.rb +2 -1
  132. data/test/collect_test.rb +4 -3
  133. data/test/collection_listing_test.rb +21 -16
  134. data/test/collection_publication_test.rb +8 -8
  135. data/test/collection_test.rb +20 -19
  136. data/test/countable_test.rb +3 -2
  137. data/test/currency_test.rb +5 -5
  138. data/test/custom_collection_test.rb +4 -3
  139. data/test/customer_saved_search_test.rb +18 -8
  140. data/test/customer_test.rb +22 -14
  141. data/test/detailed_log_subscriber_test.rb +15 -11
  142. data/test/discount_code_batch_test.rb +41 -0
  143. data/test/discount_code_test.rb +21 -15
  144. data/test/draft_order_test.rb +68 -52
  145. data/test/fixtures/assigned_fulfillment_orders.json +2 -0
  146. data/test/fixtures/discount_code_batch.json +14 -0
  147. data/test/fixtures/discount_code_batch_discount_codes.json +21 -0
  148. data/test/fixtures/fulfillment_order.json +1 -0
  149. data/test/fixtures/fulfillment_orders.json +2 -0
  150. data/test/fulfillment_event_test.rb +31 -26
  151. data/test/fulfillment_order_test.rb +215 -147
  152. data/test/fulfillment_order_test_helper.rb +1 -0
  153. data/test/fulfillment_request_test.rb +10 -8
  154. data/test/fulfillment_service_test.rb +13 -12
  155. data/test/fulfillment_test.rb +81 -66
  156. data/test/fulfillment_v2_test.rb +16 -12
  157. data/test/gift_card_test.rb +6 -4
  158. data/test/graphql_test.rb +55 -23
  159. data/test/image_test.rb +19 -17
  160. data/test/inventory_level_test.rb +24 -15
  161. data/test/lib/webmock_extensions/last_request.rb +1 -1
  162. data/test/limits_test.rb +2 -1
  163. data/test/location_test.rb +2 -1
  164. data/test/marketing_event_test.rb +20 -20
  165. data/test/message_enricher_test.rb +6 -6
  166. data/test/meta_test.rb +7 -9
  167. data/test/metafield_test.rb +30 -20
  168. data/test/order_risk_test.rb +17 -16
  169. data/test/order_test.rb +43 -28
  170. data/test/pagination_test.rb +89 -56
  171. data/test/policy_test.rb +6 -5
  172. data/test/price_rule_test.rb +20 -15
  173. data/test/product_listing_test.rb +20 -20
  174. data/test/product_publication_test.rb +8 -8
  175. data/test/product_test.rb +71 -20
  176. data/test/publication_test.rb +3 -3
  177. data/test/recurring_application_charge_test.rb +104 -42
  178. data/test/redirect_test.rb +4 -3
  179. data/test/refund_test.rb +22 -17
  180. data/test/report_test.rb +12 -10
  181. data/test/resource_feedback_test.rb +14 -13
  182. data/test/script_tag_test.rb +10 -9
  183. data/test/session_test.rb +234 -43
  184. data/test/shipping_zone_test.rb +4 -3
  185. data/test/shop_test.rb +47 -33
  186. data/test/smart_collection_test.rb +5 -29
  187. data/test/storefront_access_token_test.rb +13 -15
  188. data/test/tax_service_test.rb +7 -4
  189. data/test/tender_transaction_test.rb +3 -3
  190. data/test/test_helper.rb +14 -12
  191. data/test/transaction_test.rb +4 -3
  192. data/test/usage_charge_test.rb +12 -8
  193. data/test/user_test.rb +4 -3
  194. data/test/variant_test.rb +50 -23
  195. data/test/webhook_test.rb +10 -7
  196. metadata +30 -15
  197. data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +0 -1027
  198. data/.travis.yml +0 -23
  199. data/bin/shopify +0 -3
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class ApplicationCharge < Base
3
4
  undef_method :test
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class ApplicationCredit < Base
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class Article < Base
3
4
  include Events
@@ -7,14 +8,14 @@ module ShopifyAPI
7
8
  conditional_prefix :blog
8
9
 
9
10
  def comments
10
- Comment.find(:all, :params => { :article_id => id })
11
+ Comment.find(:all, params: { article_id: id })
11
12
  end
12
13
 
13
14
  def self.authors(options = {})
14
15
  get(:authors, options)
15
16
  end
16
17
 
17
- def self.tags(options={})
18
+ def self.tags(options = {})
18
19
  get(:tags, options)
19
20
  end
20
21
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  # Assets represent the files that comprise your theme.
3
4
  # There are different buckets which hold different kinds
@@ -9,10 +10,10 @@ module ShopifyAPI
9
10
  # or assets/bg-body.gif.
10
11
  #
11
12
  # Initialize with a key:
12
- # asset = ShopifyAPI::Asset.new(:key => 'assets/special.css', :theme_id => 12345)
13
+ # asset = ShopifyAPI::Asset.new(key: 'assets/special.css', theme_id: 12345)
13
14
  #
14
15
  # Find by key:
15
- # asset = ShopifyAPI::Asset.find('assets/image.png', :params => {:theme_id => 12345})
16
+ # asset = ShopifyAPI::Asset.find('assets/image.png', params: {theme_id: 12345})
16
17
  #
17
18
  # Get the text or binary value:
18
19
  # asset.value # decodes from attachment attribute if necessary
@@ -38,13 +39,13 @@ module ShopifyAPI
38
39
 
39
40
  conditional_prefix :theme
40
41
 
41
- def self.element_path(id, prefix_options = {}, query_options = nil) #:nodoc:
42
+ def self.element_path(_id, prefix_options = {}, query_options = nil) #:nodoc:
42
43
  prefix_options, query_options = split_options(prefix_options) if query_options.nil?
43
44
  "#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
44
45
  end
45
46
 
46
47
  # find an asset by key:
47
- # ShopifyAPI::Asset.find('layout/theme.liquid', :params => { theme_id: 99 })
48
+ # ShopifyAPI::Asset.find('layout/theme.liquid', params: { theme_id: 99 })
48
49
  def self.find(*args)
49
50
  if args[0].is_a?(Symbol)
50
51
  super
@@ -75,7 +76,7 @@ module ShopifyAPI
75
76
  end
76
77
 
77
78
  def destroy
78
- connection.delete(element_path(prefix_options.merge(:asset => {:key => key})), self.class.headers)
79
+ connection.delete(element_path(prefix_options.merge(asset: { key: key })), self.class.headers)
79
80
  end
80
81
 
81
82
  def new?
@@ -1,6 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class AssignedFulfillmentOrder < Base
3
-
4
4
  def initialize(attributes = {}, persisted = false)
5
5
  ShopifyAPI::Base.version_validation!(FulfillmentOrder::MINIMUM_VERSION)
6
6
  super(attributes, persisted)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'shopify_api/version'
2
3
 
3
4
  module ShopifyAPI
@@ -15,7 +16,7 @@ module ShopifyAPI
15
16
 
16
17
  def encode(options = {})
17
18
  same = dup
18
- same.attributes = {self.class.element_name => same.attributes} if self.class.format.extension == 'json'
19
+ same.attributes = { self.class.element_name => same.attributes } if self.class.format.extension == 'json'
19
20
 
20
21
  same.send("to_#{self.class.format.extension}", options)
21
22
  end
@@ -43,7 +44,7 @@ module ShopifyAPI
43
44
  end
44
45
 
45
46
  def activate_session(session)
46
- raise InvalidSessionError.new("Session cannot be nil") if session.nil?
47
+ raise InvalidSessionError, "Session cannot be nil" if session.nil?
47
48
  self.site = session.site
48
49
  self.headers.merge!('X-Shopify-Access-Token' => session.token)
49
50
  self.api_version = session.api_version
@@ -53,7 +54,6 @@ module ShopifyAPI
53
54
  self.site = nil
54
55
  self.password = nil
55
56
  self.user = nil
56
- self.api_version = nil
57
57
  self.headers.delete('X-Shopify-Access-Token')
58
58
  end
59
59
 
@@ -68,7 +68,11 @@ module ShopifyAPI
68
68
  end
69
69
 
70
70
  def api_version=(version)
71
- self._api_version = ApiVersion::NullVersion.matches?(version) ? ApiVersion::NullVersion : ApiVersion.find_version(version)
71
+ self._api_version = if ApiVersion::NullVersion.matches?(version)
72
+ ApiVersion::NullVersion
73
+ else
74
+ ApiVersion.find_version(version)
75
+ end
72
76
  end
73
77
 
74
78
  def prefix(options = {})
@@ -88,11 +92,11 @@ module ShopifyAPI
88
92
  def resource_prefix=(value)
89
93
  @prefix_parameters = nil
90
94
 
91
- resource_prefix_call = value.gsub(/:\w+/) { |key| "\#{URI.parser.escape options[#{key}].to_s}" }
95
+ resource_prefix_call = value.gsub(/:\w+/) { |key| "\#{URI::DEFAULT_PARSER.escape options[#{key}].to_s}" }
92
96
 
93
97
  silence_warnings do
94
98
  # Redefine the new methods.
95
- instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
99
+ instance_eval(<<-RUBY_EVAL, __FILE__, __LINE__ + 1)
96
100
  def prefix_source() "#{value}" end
97
101
  def resource_prefix(options={}) "#{resource_prefix_call}" end
98
102
  RUBY_EVAL
@@ -123,7 +127,7 @@ module ShopifyAPI
123
127
  def init_prefix_explicit(resource_type, resource_id)
124
128
  self.resource_prefix = "#{resource_type}/:#{resource_id}/"
125
129
 
126
- define_method resource_id.to_sym do
130
+ define_method(resource_id.to_sym) do
127
131
  @prefix_options[resource_id]
128
132
  end
129
133
  end
@@ -156,7 +160,7 @@ module ShopifyAPI
156
160
  private
157
161
 
158
162
  def only_id
159
- encode(:only => :id, :include => [], :methods => [])
163
+ encode(only: :id, include: [], methods: [])
160
164
  end
161
165
  end
162
166
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class BillingAddress < Base
3
4
  end
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class Blog < Base
3
4
  include Events
4
5
  include Metafields
5
6
 
6
7
  def articles
7
- Article.find(:all, :params => { :blog_id => id })
8
+ Article.find(:all, params: { blog_id: id })
8
9
  end
9
10
  end
10
11
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class CarrierService < Base
3
4
  end
@@ -1,4 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class Cart < Base
3
4
  end
4
- end
5
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  # For adding/removing products from custom collections
3
4
  class Collect < Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class CollectionListing < Base
3
4
  self.primary_key = :collection_id
@@ -1,9 +1,24 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class Comment < Base
3
- def remove; load_attributes_from_response(post(:remove, {}, only_id)); end
4
- def spam; load_attributes_from_response(post(:spam, {}, only_id)); end
5
- def approve; load_attributes_from_response(post(:approve, {}, only_id)); end
6
- def restore; load_attributes_from_response(post(:restore, {}, only_id)); end
7
- def not_spam; load_attributes_from_response(post(:not_spam, {}, only_id)); end
4
+ def remove
5
+ load_attributes_from_response(post(:remove, {}, only_id))
6
+ end
7
+
8
+ def spam
9
+ load_attributes_from_response(post(:spam, {}, only_id))
10
+ end
11
+
12
+ def approve
13
+ load_attributes_from_response(post(:approve, {}, only_id))
14
+ end
15
+
16
+ def restore
17
+ load_attributes_from_response(post(:restore, {}, only_id))
18
+ end
19
+
20
+ def not_spam
21
+ load_attributes_from_response(post(:not_spam, {}, only_id))
22
+ end
8
23
  end
9
24
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class Country < Base
3
4
  end
@@ -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, :params => {:collection_id => self.id})
8
+ Product.find(:all, params: { collection_id: self.id })
8
9
  end
9
10
 
10
11
  def add_product(product)
11
- Collect.create(:collection_id => self.id, :product_id => product.id)
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, :params => {:collection_id => self.id, :product_id => product.id})
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,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class Customer < Base
3
4
  include Metafields
4
5
 
5
6
  def orders
6
- Order.find(:all, params: {customer_id: self.id})
7
+ Order.find(:all, params: { customer_id: self.id })
7
8
  end
8
9
 
9
10
  def self.search(params)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'shopify_api/resources/customer_saved_search'
2
3
 
3
4
  module ShopifyAPI
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class CustomerInvite < Base
3
4
  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({:customer_saved_search_id => self.id}))
9
+ Customer.search(params.merge({ customer_saved_search_id: self.id }))
9
10
  end
10
11
  end
11
12
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class DiscountCode < Base
3
4
  init_prefix :price_rule
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+ module ShopifyAPI
3
+ class DiscountCodeBatch < Base
4
+ init_prefix :price_rule
5
+
6
+ self.collection_name = 'batch'
7
+
8
+ def price_rule_id
9
+ @prefix_options[:price_rule_id]
10
+ end
11
+
12
+ def discount_code_job
13
+ @discount_codes ||= begin
14
+ if id
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)
19
+ discount_codes.each do |code|
20
+ errors = code.attributes['errors']
21
+ errors.attributes.each do |key, values|
22
+ values.each { |message| code.errors.add(key, message) }
23
+ end
24
+ end
25
+ discount_codes
26
+ end
27
+ end
28
+ end
29
+
30
+ def encode(options = {})
31
+ send("to_#{self.class.format.extension}", options)
32
+ end
33
+ end
34
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class DraftOrder < Base
3
4
  include Metafields
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class DraftOrderInvoice < Base
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyAPI
2
3
  class Event < Base
3
4
  include DisablePrefixCheck
@@ -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; load_attributes_from_response(post(:cancel, {}, only_id)); end
10
- def complete; load_attributes_from_response(post(:complete, {}, only_id)); end
11
- def open; load_attributes_from_response(post(:open, {}, only_id)); end
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 FulfillmentEvent < Base
3
4
  self.resource_prefix = "orders/:order_id/fulfillments/:fulfillment_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