spree_core 6.0.2 → 6.0.4

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 (100) hide show
  1. checksums.yaml +4 -4
  2. data/app/jobs/spree/addresses/geocode_address_job.rb +6 -3
  3. data/app/jobs/spree/payments/handle_webhook_job.rb +12 -1
  4. data/app/jobs/spree/variants/remove_line_item_job.rb +5 -0
  5. data/app/models/concerns/spree/has_custom_fields.rb +4 -1
  6. data/app/models/concerns/spree/personal_data_matching.rb +5 -1
  7. data/app/models/concerns/spree/preference_schema.rb +5 -0
  8. data/app/models/concerns/spree/product_scopes.rb +2 -2
  9. data/app/models/concerns/spree/publishable.rb +26 -3
  10. data/app/models/concerns/spree/typed_associations.rb +53 -20
  11. data/app/models/spree/address.rb +2 -2
  12. data/app/models/spree/authentication/strategies/base_strategy.rb +10 -1
  13. data/app/models/spree/cart.rb +7 -2
  14. data/app/models/spree/collection.rb +7 -2
  15. data/app/models/spree/invitation.rb +6 -2
  16. data/app/models/spree/media.rb +25 -1
  17. data/app/models/spree/order.rb +6 -2
  18. data/app/models/spree/price.rb +3 -0
  19. data/app/models/spree/product.rb +21 -14
  20. data/app/models/spree/product_category.rb +7 -1
  21. data/app/models/spree/product_collection.rb +8 -1
  22. data/app/models/spree/promotion.rb +1 -2
  23. data/app/models/spree/seller.rb +93 -10
  24. data/app/models/spree/seller_requirements/complete_profile.rb +26 -7
  25. data/app/models/spree/stock_level.rb +30 -1
  26. data/app/models/spree/stock_movement.rb +1 -0
  27. data/app/services/spree/carts/destroy.rb +22 -6
  28. data/app/services/spree/collections/regenerate_products.rb +37 -15
  29. data/app/services/spree/companies/add_member.rb +9 -4
  30. data/app/services/spree/diagnostics/error_log.rb +139 -0
  31. data/app/services/spree/diagnostics/section.rb +72 -0
  32. data/app/services/spree/diagnostics/sections.rb +121 -0
  33. data/app/services/spree/diagnostics/stack.rb +73 -0
  34. data/app/services/spree/diagnostics.rb +132 -0
  35. data/app/services/spree/newsletter/subscribe.rb +8 -4
  36. data/app/services/spree/orders/create_from_cart.rb +6 -2
  37. data/app/services/spree/orders/remove_line_item.rb +16 -5
  38. data/app/services/spree/product_memberships.rb +21 -1
  39. data/app/services/spree/product_types/apply_to_products.rb +12 -2
  40. data/app/services/spree/products/auto_match_collections.rb +20 -4
  41. data/app/services/spree/stock_reservations/reserve.rb +9 -6
  42. data/app/services/spree/store_credits/apply.rb +9 -1
  43. data/app/services/spree/update_check.rb +7 -31
  44. data/app/tools/spree/agent_tools/create_export.rb +3 -1
  45. data/app/tools/spree/agent_tools/create_import.rb +1 -0
  46. data/app/tools/spree/agent_tools/create_media.rb +2 -1
  47. data/app/tools/spree/agent_tools/create_resource.rb +12 -4
  48. data/app/tools/spree/agent_tools/delete_resource.rb +12 -4
  49. data/app/tools/spree/agent_tools/describe_resource.rb +72 -6
  50. data/app/tools/spree/agent_tools/get_resource.rb +8 -5
  51. data/app/tools/spree/agent_tools/resource_write.rb +16 -3
  52. data/app/tools/spree/agent_tools/search_resources.rb +51 -20
  53. data/app/tools/spree/agent_tools/update_resource.rb +6 -6
  54. data/app/tools/spree/agent_tools/upload_file.rb +1 -0
  55. data/app/workflows/spree/carts/add_item.rb +51 -0
  56. data/app/workflows/spree/carts/complete.rb +18 -3
  57. data/app/workflows/spree/carts/merge.rb +25 -4
  58. data/app/workflows/spree/orders/complete.rb +39 -14
  59. data/app/workflows/spree/payments/handle_webhook.rb +7 -3
  60. data/app/workflows/spree/products/activate.rb +7 -2
  61. data/app/workflows/spree/products/archive.rb +7 -2
  62. data/app/workflows/spree/products/draft.rb +7 -2
  63. data/app/workflows/spree/products/status_transition.rb +24 -0
  64. data/app/workflows/spree/sellers/approve.rb +6 -0
  65. data/app/workflows/spree/sellers/create.rb +5 -2
  66. data/app/workflows/spree/stock_levels/bulk_upsert.rb +19 -7
  67. data/config/locales/be.yml +1 -1
  68. data/config/locales/en.yml +11 -0
  69. data/config/locales/fr.yml +1 -1
  70. data/config/locales/lt.yml +1 -1
  71. data/config/locales/ru.yml +1 -1
  72. data/config/locales/uk.yml +1 -1
  73. data/db/migrate/20240303174340_fix_spree_stock_item_unique_index.rb +14 -10
  74. data/db/migrate/20260814000001_rename_stock_items_to_stock_levels.rb +13 -7
  75. data/lib/generators/spree/api_resource/api_resource_generator.rb +35 -3
  76. data/lib/generators/spree/api_resource/templates/admin_controller.rb.tt +9 -4
  77. data/lib/generators/spree/api_resource/templates/admin_integration_spec.rb.tt +74 -0
  78. data/lib/generators/spree/api_resource/templates/store_controller.rb.tt +11 -6
  79. data/lib/spree/agent_tool.rb +105 -1
  80. data/lib/spree/agent_tools/default_catalog.rb +16 -21
  81. data/lib/spree/agent_tools/legacy_tools.rb +212 -0
  82. data/lib/spree/agent_tools/operation_catalog.rb +206 -0
  83. data/lib/spree/agent_tools/operation_tool.rb +189 -0
  84. data/lib/spree/agent_tools/record_summary.rb +8 -2
  85. data/lib/spree/agent_tools/registry.rb +65 -31
  86. data/lib/spree/agent_tools/resource_map.rb +207 -9
  87. data/lib/spree/agent_tools.rb +3 -3
  88. data/lib/spree/core/dependencies_helper.rb +96 -40
  89. data/lib/spree/core/engine.rb +12 -1
  90. data/lib/spree/core/version.rb +1 -1
  91. data/lib/spree/core.rb +30 -2
  92. data/lib/spree/reporting/default_vocabulary.rb +25 -5
  93. data/lib/spree/testing_support/extension_rake.rb +12 -0
  94. data/lib/spree/upgrades/5_6_to_6_0/manifest.yml +34 -0
  95. data/lib/tasks/dependencies.rake +2 -2
  96. data/lib/tasks/diagnostics.rake +11 -0
  97. metadata +29 -7
  98. data/lib/spree/agent_tools/workflow_endpoints.rb +0 -88
  99. data/lib/spree/agent_tools/workflow_schema.rb +0 -279
  100. data/lib/spree/agent_tools/workflow_tool.rb +0 -654
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'swagger_helper'
4
+
5
+ # Documents the <%= plural_name.humanize(capitalize: false) %> Admin API in openapi/admin.yaml (`spree task
6
+ # openapi:generate`). The SDK request types come from these operations, and
7
+ # each action other than create, read, update and delete becomes an agent tool.
8
+ RSpec.describe '<%= plural_name.humanize %> Admin API', type: :request, swagger_doc: 'openapi/admin.yaml' do
9
+ let!(:<%= singular_name %>) { create(:<%= singular_name %>) }
10
+
11
+ path '/api/v3/admin/<%= plural_name %>' do
12
+ get 'List <%= plural_name.humanize(capitalize: false) %>' do
13
+ tags '<%= plural_name.humanize %>'
14
+ admin_operation :read, :<%= plural_name %>, description: 'Lists the <%= plural_name.humanize(capitalize: false) %>.'
15
+ parameter name: :page, in: :query, type: :integer, required: false, description: 'Page number'
16
+ parameter name: :limit, in: :query, type: :integer, required: false, description: 'Number of records per page'
17
+ filter_parameters_for
18
+
19
+ response '200', '<%= plural_name.humanize(capitalize: false) %> found' do
20
+ run_test! do |response|
21
+ expect(JSON.parse(response.body)['data'].map { |record| record['id'] }).to include(<%= singular_name %>.prefixed_id)
22
+ end
23
+ end
24
+ end
25
+
26
+ post 'Create a <%= singular_name.humanize(capitalize: false) %>' do
27
+ tags '<%= plural_name.humanize %>'
28
+ admin_operation :write, :<%= plural_name %>, description: 'Creates a <%= singular_name.humanize(capitalize: false) %>.'
29
+ request_body_for
30
+
31
+ response '201', '<%= singular_name.humanize(capitalize: false) %> created' do
32
+ let(:body) { attributes_for(:<%= singular_name %>).slice(<%= permitted_attribute_names.map { |a| ":#{a}" }.join(', ') %>)<%= decimal_attribute_names.map { |a| ".merge(#{a}: '1.00')" }.join %> }
33
+
34
+ run_test!
35
+ end
36
+ end
37
+ end
38
+
39
+ path '/api/v3/admin/<%= plural_name %>/{id}' do
40
+ parameter name: :id, in: :path, type: :string, required: true, description: '<%= singular_name.humanize %> ID'
41
+
42
+ let(:id) { <%= singular_name %>.prefixed_id }
43
+
44
+ get 'Get a <%= singular_name.humanize(capitalize: false) %>' do
45
+ tags '<%= plural_name.humanize %>'
46
+ admin_operation :read, :<%= plural_name %>, description: 'Returns a <%= singular_name.humanize(capitalize: false) %>.'
47
+
48
+ response '200', '<%= singular_name.humanize(capitalize: false) %> found' do
49
+ run_test!
50
+ end
51
+ end
52
+
53
+ patch 'Update a <%= singular_name.humanize(capitalize: false) %>' do
54
+ tags '<%= plural_name.humanize %>'
55
+ admin_operation :write, :<%= plural_name %>, description: 'Updates a <%= singular_name.humanize(capitalize: false) %>.'
56
+ request_body_for
57
+
58
+ response '200', '<%= singular_name.humanize(capitalize: false) %> updated' do
59
+ let(:body) { attributes_for(:<%= singular_name %>).slice(<%= permitted_attribute_names.map { |a| ":#{a}" }.join(', ') %>)<%= decimal_attribute_names.map { |a| ".merge(#{a}: '1.00')" }.join %> }
60
+
61
+ run_test!
62
+ end
63
+ end
64
+
65
+ delete 'Delete a <%= singular_name.humanize(capitalize: false) %>' do
66
+ tags '<%= plural_name.humanize %>'
67
+ admin_operation :write, :<%= plural_name %>, description: 'Deletes a <%= singular_name.humanize(capitalize: false) %>.'
68
+
69
+ response '204', '<%= singular_name.humanize(capitalize: false) %> deleted' do
70
+ run_test!
71
+ end
72
+ end
73
+ end
74
+ end
@@ -3,6 +3,17 @@ module Spree
3
3
  module V3
4
4
  module Store
5
5
  class <%= plural_name.camelize %>Controller < ResourceController
6
+ <% if writable? -%>
7
+ # What create and update accept: the controller permits from it, and
8
+ # the integration spec documents it (`request_body_for`), which is
9
+ # where the SDK request types come from.
10
+ request_params :<%= singular_name %> do |body|
11
+ <% request_param_attributes.each do |name, type, required| -%>
12
+ body.attribute :<%= name %>, :<%= type %><%= ', required: true, on: :create' if required %>
13
+ <% end -%>
14
+ end
15
+
16
+ <% end -%>
6
17
  protected
7
18
 
8
19
  def model_class
@@ -17,12 +28,6 @@ module Spree
17
28
  def serializer_class
18
29
  Spree::Api::V3::<%= bare_class_name %>Serializer
19
30
  end
20
- <% end -%>
21
- <% if writable? -%>
22
-
23
- def resource_permitted_attributes
24
- [<%= permitted_attribute_names.map { |a| ":#{a}" }.join(', ') %>]
25
- end
26
31
  <% end -%>
27
32
  end
28
33
  end
@@ -21,6 +21,12 @@ module Spree
21
21
  # end
22
22
  # end
23
23
  class AgentTool
24
+ # The parameter every generic resource tool takes for a resource that
25
+ # lives under another record, such as an order's items.
26
+ PARENT_ID_DESCRIPTION = 'For a resource reached through another record (describe_resource names ' \
27
+ 'it as parent or listed_under, e.g. an order for its items and claims, a ' \
28
+ 'category for its products): that record\'s id as shown in search results'.freeze
29
+
24
30
  # Declarations live in class attributes rather than plain class-level
25
31
  # instance variables so a subclass inherits them. Subclassing a tool to
26
32
  # tweak it is the documented extension path, and with bare ivars the
@@ -85,6 +91,26 @@ class AgentTool
85
91
  declared_mutating == true
86
92
  end
87
93
 
94
+ # Declares that this tool only adds — it creates a record or a file and
95
+ # never overwrites, removes or changes the state of one that exists.
96
+ # Every other mutating tool counts as destructive, so a tool that
97
+ # forgets to say is warned about more, never less.
98
+ #
99
+ # Unlike the declarations above, this one is not inherited: a subclass
100
+ # that overrides `call` may well change existing data, so it is
101
+ # destructive until it says otherwise itself.
102
+ #
103
+ # @return [void]
104
+ def additive!
105
+ @additive = true
106
+ end
107
+
108
+ # @return [Boolean] whether the tool may overwrite, remove or change
109
+ # the state of existing data
110
+ def destructive?
111
+ mutating? && @additive != true
112
+ end
113
+
88
114
  # @param name [Symbol]
89
115
  # @param type [Symbol] JSON schema type
90
116
  # @param description [String]
@@ -105,6 +131,44 @@ class AgentTool
105
131
  def params
106
132
  declared_params
107
133
  end
134
+
135
+ # The declared params as JSON Schema, which is what an adapter hands a
136
+ # client. A tool built from an OpenAPI operation overrides this with the
137
+ # operation's own schema, nested properties included.
138
+ #
139
+ # @return [Hash]
140
+ def input_schema
141
+ properties = params.to_h do |name, options|
142
+ property = { 'type' => json_type(options[:type]) }
143
+ property['description'] = options[:description] if options[:description].present?
144
+ # An array must say what it holds: a client validating arguments
145
+ # against the schema refuses the call otherwise.
146
+ property['items'] = { 'type' => json_type(options[:items] || :string) } if property['type'] == 'array'
147
+
148
+ [name.to_s, property]
149
+ end
150
+
151
+ {
152
+ 'type' => 'object',
153
+ 'properties' => properties,
154
+ 'required' => params.select { |_name, options| options[:required] }.keys.map(&:to_s)
155
+ }
156
+ end
157
+
158
+ private
159
+
160
+ # A tool declares Ruby-ish types; JSON Schema wants its own names, and
161
+ # anything unrecognised is a string, which every client can render.
162
+ def json_type(type)
163
+ case type&.to_sym
164
+ when :boolean then 'boolean'
165
+ when :integer then 'integer'
166
+ when :number, :float, :decimal then 'number'
167
+ when :object, :hash then 'object'
168
+ when :array then 'array'
169
+ else 'string'
170
+ end
171
+ end
108
172
  end
109
173
 
110
174
  # @return [Spree::AgentTools::Context] who is asking, and where
@@ -115,7 +179,7 @@ class AgentTool
115
179
  @context = context
116
180
  end
117
181
 
118
- delegate :tool_name, :description, :permission, :mutating?, :params, to: :class
182
+ delegate :tool_name, :description, :permission, :mutating?, :destructive?, :params, to: :class
119
183
 
120
184
  # Runs the tool. Subclasses implement this with keyword arguments matching
121
185
  # their declared params.
@@ -167,6 +231,46 @@ class AgentTool
167
231
 
168
232
  protected
169
233
 
234
+ # A resource that lives under a parent — a promotion's rules, an order's
235
+ # payments — has no path of its own to dispatch to, so every tool refuses
236
+ # it the same way: naming the parent and, where the parent carries the
237
+ # rows as an attribute, how to write and read them there. The old answer
238
+ # was the endpoint's 404 for a parent id nobody supplied.
239
+ #
240
+ # @param entry [Spree::AgentTools::ResourceMap::Entry]
241
+ # @param verb [String] 'searched', 'fetched', 'created'…
242
+ # @param action [Symbol] the operation whose path runs under the parent
243
+ # @return [Hash]
244
+ def nested_resource_error(entry, verb, action)
245
+ # A top-level path left unfilled is missing its own id, not a parent.
246
+ return { error: "Pass the id of the #{entry.key.singularize.tr('_', ' ')} to use." } unless entry.nested?(action)
247
+
248
+ parent = entry.parent_key(action)
249
+ parent_entry = Spree::AgentTools::ResourceMap.find(parent)
250
+ attribute = parent_entry&.nested_typed_families&.key(entry.model_class)
251
+
252
+ owner = parent.singularize.tr('_', ' ')
253
+ sentences = ["#{entry.key} belong to #{owner.match?(/\A[aeiou]/) ? 'an' : 'a'} #{owner} and cannot be #{verb} on their own."]
254
+ # Offered only where one parent id fills the path; a resource nested
255
+ # twice has no generic route.
256
+ reachable = entry.path_for(action, id: 'id', parent_id: 'parent').present?
257
+ sentences << "Pass the #{owner}'s id as parent_id to reach them under it." if reachable
258
+ # Each suggested call is one this caller may actually make; a hint
259
+ # that leads straight to a permission refusal is worse than none.
260
+ readable = parent_entry&.readable_by?(context)
261
+ writable = parent_entry&.write_permission.present? && context.permitted?(parent_entry.write_permission)
262
+ if attribute && writable
263
+ sentences << "Write them in the #{attribute} attribute of #{parent} — describe_resource #{parent} shows the shape and the accepted types."
264
+ end
265
+ if attribute && readable && parent_entry.expandable_associations.include?(attribute)
266
+ sentences << "Read them with get_resource on #{parent} and expand: [\"#{attribute}\"]."
267
+ elsif readable && !attribute
268
+ sentences << "Start from #{parent}: get_resource with expand lists what it carries (describe_resource #{parent} names the options)."
269
+ end
270
+
271
+ { error: sentences.join(' '), parent: parent }
272
+ end
273
+
170
274
  # Refuses unless this admin may take `action` on `record`.
171
275
  #
172
276
  # Holding `write_products` says an admin may edit products; it does not
@@ -1,15 +1,11 @@
1
1
  module Spree
2
2
  module AgentTools
3
- # The tools Spree ships: the generic read tools, and the workflows exposed
4
- # as write tools.
3
+ # The hand-written tools Spree ships: the generic reads and writes,
4
+ # reporting, imports, files and stock.
5
5
  #
6
- # The write allowlist is the whole catalog of back-office writes an agent
7
- # may make. Every entry names a `Spree::Dependencies` key, so a host app
8
- # that swaps in its own workflow class keeps the tool and gets the
9
- # replacement's schema; and a permission, which must equal the write scope
10
- # of the admin controller that invokes the same workflow — a contract spec
11
- # in `spree_api` fails when the two disagree, or when a controller gains a
12
- # workflow that is neither listed here nor excluded below.
6
+ # Back-office actions are not listed here. Every Admin API action is a
7
+ # tool built from its OpenAPI operation ({OperationCatalog}); an action
8
+ # that should not be one is marked in its rswag spec, with the reason.
13
9
  module DefaultCatalog
14
10
  # Read tools, and the writes that are not workflows.
15
11
  TOOLS = %w[
@@ -33,15 +29,11 @@ module Spree
33
29
  ].freeze
34
30
 
35
31
 
36
- # Workflow key => permission, or => {permission:, except:, summary:}.
32
+ # @deprecated The 6.0.0 workflow allowlist, kept only so a reference to
33
+ # it does not break through 6.0.x. Nothing reads it: Admin API
34
+ # operations are tools on their own. Removed in 6.1.
37
35
  WORKFLOWS = {
38
36
  # Catalog
39
- #
40
- # The three status moves below run in this process rather than through
41
- # an endpoint, because the Admin API has none for them: `PATCH` writes
42
- # the column and the bulk action uses `update_all`, so neither
43
- # publishes the status event nor withdraws an open seller submission.
44
- # They dispatch as soon as an admin status endpoint exists.
45
37
  product_activate_workflow: 'write_products',
46
38
  product_draft_workflow: 'write_products',
47
39
  product_archive_workflow: 'write_products',
@@ -59,8 +51,10 @@ module Spree
59
51
 
60
52
  # Orders. `restock_items` is hidden: it is deprecated and ignored, so
61
53
  # offering it would invite a model to set something that does nothing.
54
+ # `validated` is for callers that already ran their own veto; offered
55
+ # to a model it would be a way around orders.complete.validate.
62
56
  order_cancel_workflow: { permission: 'write_orders', except: %i[restock_items] },
63
- order_complete_workflow: 'write_orders',
57
+ order_complete_workflow: { permission: 'write_orders', except: %i[validated] },
64
58
 
65
59
  # Fulfillment
66
60
  fulfillment_create_workflow: 'write_fulfillments',
@@ -103,9 +97,9 @@ module Spree
103
97
  tax_exemption_certificate_verify_workflow: 'write_customers'
104
98
  }.freeze
105
99
 
106
- # Workflows an admin controller invokes that are deliberately NOT tools,
107
- # each with the reason. The contract spec reads this list, so a workflow
108
- # can never be quietly dropped: it is exposed, or it is here.
100
+ # @deprecated The 6.0.0 exclusion list, kept like {WORKFLOWS}. Its
101
+ # reasons now travel as `agent_tool false, reason:` on the operation's
102
+ # rswag spec. Removed in 6.1.
109
103
  # The email template editor is a draft-and-publish surface: its steps
110
104
  # move a draft through revisions against a live preview, and they mean
111
105
  # nothing outside that screen. Publishing one sends real mail in the
@@ -172,9 +166,10 @@ module Spree
172
166
  # @return [void]
173
167
  def install(registry)
174
168
  TOOLS.each { |tool| registry << tool }
175
- registry.expose_workflows(**WORKFLOWS)
176
169
  end
177
170
  end
171
+
172
+ deprecate_constant :WORKFLOWS, :EXCLUDED_WORKFLOWS
178
173
  end
179
174
  end
180
175
  end
@@ -0,0 +1,212 @@
1
+ module Spree
2
+ module AgentTools
3
+ # The workflow tools Spree 6.0.0 offered, by the name and parameters a
4
+ # client saw then, and the operation each now runs.
5
+ #
6
+ # 6.0.0 derived a tool from a workflow's `perform` signature, so its
7
+ # parameters were the workflow's keywords (`order`, `reason`); a tool now
8
+ # takes the operation's own (`id`, `cancel_reason_id`). This table, written
9
+ # once from the 6.0.0 schemas, keeps those calls working through 6.0.x. It
10
+ # is an explicit list, not a rule: nothing here guesses one name from
11
+ # another.
12
+ #
13
+ # A parameter mapped to nil never reached the endpoint in 6.0.0 either; it
14
+ # is ignored, and the result says so. One mapped to `:merge` was a hash of
15
+ # fields, merged into the body, which is what 6.0.0 did with it.
16
+ #
17
+ # `deliveries_update_tracking` is not here: 6.0.0 sent it to the
18
+ # mark-delivered endpoint and dropped its tracking fields, so a call meant
19
+ # to record tracking marked the delivery delivered. No endpoint sets a
20
+ # carrier status, so the name no longer answers rather than doing that.
21
+ #
22
+ # Removed in 6.1, with the names that are no longer listed.
23
+ # See docs/plans/6.0-agent-tools-from-openapi.md.
24
+ module LegacyTools
25
+ # Old tool name => the operation it runs and its renamed parameters.
26
+ TOOLS = {
27
+ 'catalogs_activate' => {
28
+ verb: 'patch', path: '/api/v3/admin/catalogs/{id}/activate',
29
+ parameters: { 'catalog' => 'id' }
30
+ },
31
+ 'catalogs_deactivate' => {
32
+ verb: 'patch', path: '/api/v3/admin/catalogs/{id}/deactivate',
33
+ parameters: { 'catalog' => 'id' }
34
+ },
35
+ 'fulfillments_create' => {
36
+ verb: 'post', path: '/api/v3/admin/orders/{order_id}/fulfillments',
37
+ parameters: {
38
+ 'order' => 'order_id', 'stock_location' => 'stock_location_id',
39
+ 'source_fulfillment' => 'source_fulfillment_id', 'delivery_method' => 'delivery_method_id'
40
+ }
41
+ },
42
+ 'fulfillments_mark_delivered' => {
43
+ verb: 'patch', path: '/api/v3/admin/orders/{order_id}/fulfillments/{id}/mark_delivered',
44
+ parameters: { 'fulfillment' => 'id' }
45
+ },
46
+ 'orders_cancel' => {
47
+ verb: 'patch', path: '/api/v3/admin/orders/{id}/cancel',
48
+ parameters: { 'order' => 'id', 'canceled_at' => nil, 'reason' => 'cancel_reason_id', 'note' => 'cancel_note' }
49
+ },
50
+ 'orders_complete' => {
51
+ verb: 'patch', path: '/api/v3/admin/orders/{id}/complete',
52
+ parameters: { 'order' => 'id' }
53
+ },
54
+ 'payments_capture' => {
55
+ verb: 'patch', path: '/api/v3/admin/orders/{order_id}/payments/{id}/capture',
56
+ parameters: { 'payment' => 'id' }
57
+ },
58
+ 'payments_void' => {
59
+ verb: 'patch', path: '/api/v3/admin/orders/{order_id}/payments/{id}/void',
60
+ parameters: { 'payment' => 'id' }
61
+ },
62
+ 'price_lists_activate' => {
63
+ verb: 'patch', path: '/api/v3/admin/price_lists/{id}/activate',
64
+ parameters: { 'price_list' => 'id' }
65
+ },
66
+ 'price_lists_deactivate' => {
67
+ verb: 'patch', path: '/api/v3/admin/price_lists/{id}/deactivate',
68
+ parameters: { 'price_list' => 'id' }
69
+ },
70
+ 'products_activate' => {
71
+ verb: 'patch', path: '/api/v3/admin/products/{id}/activate',
72
+ parameters: { 'product' => 'id' }
73
+ },
74
+ 'products_approve' => {
75
+ verb: 'patch', path: '/api/v3/admin/products/{id}/approve',
76
+ parameters: { 'product' => 'id' }
77
+ },
78
+ 'products_archive' => {
79
+ verb: 'patch', path: '/api/v3/admin/products/{id}/archive',
80
+ parameters: { 'product' => 'id' }
81
+ },
82
+ 'products_draft' => {
83
+ verb: 'patch', path: '/api/v3/admin/products/{id}/draft',
84
+ parameters: { 'product' => 'id' }
85
+ },
86
+ 'products_reject' => {
87
+ verb: 'patch', path: '/api/v3/admin/products/{id}/reject',
88
+ parameters: { 'product' => 'id' }
89
+ },
90
+ 'purchase_orders_cancel' => {
91
+ verb: 'patch', path: '/api/v3/admin/purchase_orders/{id}/cancel',
92
+ parameters: { 'purchase_order' => 'id' }
93
+ },
94
+ 'purchase_orders_close' => {
95
+ verb: 'patch', path: '/api/v3/admin/purchase_orders/{id}/close',
96
+ parameters: { 'purchase_order' => 'id' }
97
+ },
98
+ 'purchase_orders_mark_draft' => {
99
+ verb: 'patch', path: '/api/v3/admin/purchase_orders/{id}/mark_draft',
100
+ parameters: { 'purchase_order' => 'id' }
101
+ },
102
+ 'purchase_orders_mark_ordered' => {
103
+ verb: 'patch', path: '/api/v3/admin/purchase_orders/{id}/mark_ordered',
104
+ parameters: { 'purchase_order' => 'id' }
105
+ },
106
+ 'purchase_orders_receive' => {
107
+ verb: 'post', path: '/api/v3/admin/purchase_orders/{purchase_order_id}/stock_receipts',
108
+ parameters: { 'purchase_order' => 'purchase_order_id' }
109
+ },
110
+ 'refunds_create' => {
111
+ verb: 'post', path: '/api/v3/admin/orders/{order_id}/refunds',
112
+ parameters: {
113
+ 'payment' => 'payment_id', 'reason' => 'refund_reason_id', 'originator' => nil,
114
+ 'order' => 'order_id', 'tax_amount' => nil
115
+ }
116
+ },
117
+ 'seller_requirement_submissions_accept' => {
118
+ verb: 'patch', path: '/api/v3/admin/sellers/{seller_id}/requirement_submissions/{id}/accept',
119
+ parameters: { 'submission' => 'id' }
120
+ },
121
+ 'seller_requirement_submissions_reject' => {
122
+ verb: 'patch', path: '/api/v3/admin/sellers/{seller_id}/requirement_submissions/{id}/reject',
123
+ parameters: { 'submission' => 'id' }
124
+ },
125
+ 'seller_requirement_submissions_waive' => {
126
+ verb: 'post', path: '/api/v3/admin/sellers/{seller_id}/requirement_submissions',
127
+ parameters: { 'seller' => 'seller_id', 'requirement' => 'requirement_id' }
128
+ },
129
+ 'sellers_approve' => {
130
+ verb: 'patch', path: '/api/v3/admin/sellers/{id}/approve',
131
+ parameters: { 'seller' => 'id' }
132
+ },
133
+ 'sellers_invite' => {
134
+ verb: 'post', path: '/api/v3/admin/sellers/{id}/invite',
135
+ parameters: { 'seller' => 'id', 'inviter' => nil, 'role' => 'role_id' }
136
+ },
137
+ 'sellers_reject' => {
138
+ verb: 'patch', path: '/api/v3/admin/sellers/{id}/reject',
139
+ parameters: { 'seller' => 'id' }
140
+ },
141
+ 'sellers_reopen_onboarding' => {
142
+ verb: 'patch', path: '/api/v3/admin/sellers/{id}/reopen_onboarding',
143
+ parameters: { 'seller' => 'id' }
144
+ },
145
+ 'sellers_suspend' => {
146
+ verb: 'patch', path: '/api/v3/admin/sellers/{id}/suspend',
147
+ parameters: { 'seller' => 'id' }
148
+ },
149
+ 'shipping_labels_purchase' => {
150
+ verb: 'post', path: '/api/v3/admin/orders/{order_id}/fulfillments/{fulfillment_id}/labels',
151
+ parameters: { 'owner' => 'fulfillment_id' }
152
+ },
153
+ 'shipping_labels_refund' => {
154
+ verb: 'patch', path: '/api/v3/admin/orders/{order_id}/fulfillments/{fulfillment_id}/labels/{id}/refund',
155
+ parameters: { 'shipping_label' => 'id' }
156
+ },
157
+ 'stock_transfers_cancel' => {
158
+ verb: 'patch', path: '/api/v3/admin/stock_transfers/{id}/cancel',
159
+ parameters: { 'stock_transfer' => 'id' }
160
+ },
161
+ 'stock_transfers_close' => {
162
+ verb: 'patch', path: '/api/v3/admin/stock_transfers/{id}/close',
163
+ parameters: { 'stock_transfer' => 'id' }
164
+ },
165
+ 'stock_transfers_mark_draft' => {
166
+ verb: 'patch', path: '/api/v3/admin/stock_transfers/{id}/mark_draft',
167
+ parameters: { 'stock_transfer' => 'id' }
168
+ },
169
+ 'stock_transfers_mark_in_transit' => {
170
+ verb: 'patch', path: '/api/v3/admin/stock_transfers/{id}/mark_in_transit',
171
+ parameters: { 'stock_transfer' => 'id' }
172
+ },
173
+ 'stock_transfers_mark_ready' => {
174
+ verb: 'patch', path: '/api/v3/admin/stock_transfers/{id}/mark_ready',
175
+ parameters: { 'stock_transfer' => 'id' }
176
+ },
177
+ 'stock_transfers_receive' => {
178
+ verb: 'post', path: '/api/v3/admin/stock_transfers/{stock_transfer_id}/stock_receipts',
179
+ parameters: { 'stock_transfer' => 'stock_transfer_id' }
180
+ },
181
+ 'tax_exemption_certificates_verify' => {
182
+ verb: 'patch', path: '/api/v3/admin/companies/{company_id}/tax_exemption_certificates/{id}/verify',
183
+ parameters: { 'certificate' => 'id' }
184
+ },
185
+ 'variants_create' => {
186
+ verb: 'post', path: '/api/v3/admin/products/{product_id}/variants',
187
+ parameters: { 'product' => 'product_id', 'attributes' => :merge }
188
+ },
189
+ 'variants_update' => {
190
+ verb: 'patch', path: '/api/v3/admin/products/{product_id}/variants/{id}',
191
+ parameters: { 'variant' => 'id', 'attributes' => :merge }
192
+ }
193
+ }.freeze
194
+
195
+ class << self
196
+ # The 6.0.0 parameters of a tool that keeps its name, when it still
197
+ # runs the same operation.
198
+ #
199
+ # @param name [String]
200
+ # @param verb [String]
201
+ # @param path [String] the OpenAPI path
202
+ # @return [Hash{String => String, Symbol, nil}]
203
+ def parameters_for(name, verb, path)
204
+ tool = TOOLS[name.to_s]
205
+ return {} unless tool && tool[:verb] == verb.to_s && tool[:path] == path
206
+
207
+ tool[:parameters]
208
+ end
209
+ end
210
+ end
211
+ end
212
+ end