spree_api 6.0.3 → 6.0.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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -5
  3. data/app/controllers/concerns/spree/api/v3/idempotent.rb +10 -1
  4. data/app/controllers/concerns/spree/api/v3/security_headers.rb +3 -0
  5. data/app/controllers/concerns/spree/api/v3/storefront_gating.rb +4 -2
  6. data/app/controllers/spree/api/v3/admin/base_controller.rb +31 -0
  7. data/app/controllers/spree/api/v3/admin/categories_controller.rb +1 -1
  8. data/app/controllers/spree/api/v3/admin/companies/memberships_controller.rb +21 -4
  9. data/app/controllers/spree/api/v3/admin/diagnostics_controller.rb +46 -0
  10. data/app/controllers/spree/api/v3/admin/me_controller.rb +0 -13
  11. data/app/controllers/spree/api/v3/admin/media_controller.rb +10 -0
  12. data/app/controllers/spree/api/v3/admin/orders/items_controller.rb +6 -2
  13. data/app/controllers/spree/api/v3/admin/sellers/invitations_controller.rb +39 -3
  14. data/app/controllers/spree/api/v3/admin/sellers/team_controller.rb +1 -3
  15. data/app/controllers/spree/api/v3/admin/sellers_controller.rb +24 -1
  16. data/app/controllers/spree/api/v3/admin/stock_levels_controller.rb +15 -1
  17. data/app/controllers/spree/api/v3/admin/store_controller.rb +9 -1
  18. data/app/controllers/spree/api/v3/admin/updates_controller.rb +4 -15
  19. data/app/controllers/spree/api/v3/seller/option_types_controller.rb +41 -0
  20. data/app/controllers/spree/api/v3/seller/products/media_controller.rb +46 -0
  21. data/app/controllers/spree/api/v3/seller/products_controller.rb +39 -2
  22. data/app/controllers/spree/api/v3/seller/profile_controller.rb +13 -5
  23. data/app/controllers/spree/api/v3/store/carts/store_credits_controller.rb +7 -3
  24. data/app/controllers/spree/api/v3/store/carts_controller.rb +11 -8
  25. data/app/controllers/spree/api/v3/store/categories_controller.rb +1 -1
  26. data/app/controllers/spree/api/v3/store/companies/addresses_controller.rb +1 -1
  27. data/app/controllers/spree/api/v3/store/store_controller.rb +3 -2
  28. data/app/request_schemas/spree/api/v3/seller/variant_request_schema.rb +4 -0
  29. data/app/request_schemas/spree/api/v3/store/address_request_schema.rb +2 -2
  30. data/app/serializers/spree/api/v3/address_serializer.rb +3 -3
  31. data/app/serializers/spree/api/v3/admin/address_serializer.rb +1 -1
  32. data/app/serializers/spree/api/v3/admin/company_membership_serializer.rb +4 -0
  33. data/app/serializers/spree/api/v3/admin/diagnostics_serializer.rb +30 -0
  34. data/app/serializers/spree/api/v3/admin/line_item_serializer.rb +6 -1
  35. data/app/serializers/spree/api/v3/admin/market_serializer.rb +1 -1
  36. data/app/serializers/spree/api/v3/admin/refund_serializer.rb +1 -1
  37. data/app/serializers/spree/api/v3/admin/seller_serializer.rb +10 -0
  38. data/app/serializers/spree/api/v3/admin/stock_location_serializer.rb +1 -1
  39. data/app/serializers/spree/api/v3/admin/store_serializer.rb +0 -7
  40. data/app/serializers/spree/api/v3/base_serializer.rb +1 -1
  41. data/app/serializers/spree/api/v3/cart_serializer.rb +4 -3
  42. data/app/serializers/spree/api/v3/country_serializer.rb +1 -1
  43. data/app/serializers/spree/api/v3/currency_serializer.rb +3 -2
  44. data/app/serializers/spree/api/v3/locale_serializer.rb +1 -1
  45. data/app/serializers/spree/api/v3/market_serializer.rb +2 -2
  46. data/app/serializers/spree/api/v3/price_history_serializer.rb +1 -1
  47. data/app/serializers/spree/api/v3/price_serializer.rb +2 -2
  48. data/app/serializers/spree/api/v3/product_category_serializer.rb +26 -0
  49. data/app/serializers/spree/api/v3/product_collection_serializer.rb +26 -0
  50. data/app/serializers/spree/api/v3/refund_serializer.rb +2 -2
  51. data/app/serializers/spree/api/v3/seller/address_serializer.rb +1 -1
  52. data/app/serializers/spree/api/v3/seller/option_type_serializer.rb +18 -0
  53. data/app/serializers/spree/api/v3/seller/order_line_item_serializer.rb +2 -2
  54. data/app/serializers/spree/api/v3/seller/product_serializer.rb +1 -1
  55. data/app/serializers/spree/api/v3/seller/product_type_serializer.rb +8 -7
  56. data/app/serializers/spree/api/v3/seller/stock_location_serializer.rb +1 -1
  57. data/app/serializers/spree/api/v3/stock_location_serializer.rb +3 -3
  58. data/app/serializers/spree/api/v3/store_serializer.rb +17 -5
  59. data/app/services/spree/api/v3/request_schema.rb +1 -1
  60. data/config/routes.rb +9 -2
  61. data/lib/spree/api/agent_resource_map.rb +42 -7
  62. data/lib/spree/api/dependencies.rb +6 -6
  63. data/lib/spree/api/oauth.rb +8 -19
  64. data/lib/spree/api/openapi/path_sorter.rb +91 -74
  65. data/lib/spree/api/testing_support/openapi.rb +2 -1
  66. data/lib/spree/api/testing_support/sdk_method.rb +34 -0
  67. data/lib/spree/api/typelizer_generation.rb +1 -1
  68. data/openapi/admin.yaml +34498 -34007
  69. data/openapi/store.yaml +9144 -9102
  70. metadata +14 -6
@@ -62,8 +62,10 @@ module Spree
62
62
  # operator's endpoint: it would make the server fetch a URL the
63
63
  # caller chose.
64
64
  body.attribute :media, :array,
65
- as: 'SellerProductMediaParams',
66
- description: 'The gallery, as a whole: a file absent from the list is removed. `signed_id` attaches a fresh upload; `id` updates one already there.' do |media_item|
65
+ as: 'SellerProductMediaParams',
66
+ description: 'Files to add or update: `signed_id` attaches a fresh upload; ' \
67
+ '`id` updates one already there. A file left out stays; remove ' \
68
+ 'one with `DELETE /products/{product_id}/media/{id}`.' do |media_item|
67
69
  media_item.attribute :id, :id
68
70
  media_item.attribute :signed_id, :string, description: 'A `signed_id` from `POST /files`.'
69
71
  media_item.include_attributes Spree::Api::V3::MediaRequestSchema
@@ -100,6 +102,7 @@ module Spree
100
102
 
101
103
  before_action :set_status_resource, only: [:submit, :draft, :archive]
102
104
  before_action :require_ids!, only: [:bulk_submit, :bulk_status_update, :bulk_destroy]
105
+ before_action :refuse_unknown_variant_options, only: [:create, :update]
103
106
 
104
107
  # PATCH /api/v3/seller/products/:id/submit
105
108
  #
@@ -301,6 +304,40 @@ module Spree
301
304
 
302
305
  private
303
306
 
307
+ # A seller builds variants from the marketplace's option types and
308
+ # values and never adds to them, but `Variant#options=` creates
309
+ # whatever a payload names. Each option is matched here the way that
310
+ # writer matches it, against this store's vocabulary, so an unknown
311
+ # name is a 422 before anything is written.
312
+ def refuse_unknown_variant_options
313
+ # `create` authorizes inside the action, after this filter: a
314
+ # caller who may not create a product is told that, not which of
315
+ # the marketplace's options their payload missed.
316
+ authorize_resource!(build_resource, :create) if action_name == 'create'
317
+
318
+ requested = Array(params[:variants]).grep(ActionController::Parameters).
319
+ flat_map { |variant| Array(variant[:options]).grep(ActionController::Parameters) }.
320
+ select { |option| option[:name].present? && option[:value].present? }.
321
+ map { |option| [option[:name], option[:value]] }
322
+ unknown = Spree::OptionType.unknown_options(current_store, requested)
323
+ return if unknown.empty?
324
+
325
+ errors = ActiveModel::Errors.new(Spree::Product.new)
326
+ unknown.each do |option|
327
+ if option[:option_type].nil?
328
+ errors.add(:variants, :unknown_option_type,
329
+ message: I18n.t('spree.errors.messages.unknown_option_type', name: option[:name]))
330
+ else
331
+ errors.add(:variants, :unknown_option_value,
332
+ message: I18n.t('spree.errors.messages.unknown_option_value',
333
+ value: option[:value],
334
+ option_type: option[:option_type].label.presence || option[:option_type].name))
335
+ end
336
+ end
337
+
338
+ render_validation_error(errors)
339
+ end
340
+
304
341
  # 422s when the caller omits `ids` entirely, matching the operator's
305
342
  # bulk endpoints. An explicit empty array is a no-op, which is what a
306
343
  # UI whose selection was cleared between render and submit sends.
@@ -8,10 +8,10 @@ module Spree
8
8
  # `current_seller` — never an id from the request. A seller cannot
9
9
  # address another seller here even by guessing one.
10
10
  #
11
- # What they may change is presentation, contact and addresses. Absent
12
- # by design: `status` (the lifecycle belongs to the operator's
13
- # workflows), the settlement and tax configuration, and `slug` — a
14
- # seller renaming their own storefront address breaks every link
11
+ # What they may change is presentation, contact, addresses and holiday
12
+ # mode. Absent by design: `status` (the lifecycle belongs to the
13
+ # operator's workflows), the settlement and tax configuration, and
14
+ # `slug` — a seller renaming their own storefront address breaks every link
15
15
  # pointing at it.
16
16
  class ProfileController < Seller::BaseController
17
17
  # A singular resource, so this extends the plain base rather than
@@ -42,6 +42,9 @@ module Spree
42
42
  body.attribute :cover_photo_signed_id, :string,
43
43
  nullable: true,
44
44
  description: 'A `signed_id` from `POST /files`; `null` removes the image.'
45
+ body.attribute :holiday_mode_until, :datetime,
46
+ nullable: true,
47
+ description: 'Set while the seller is away: the catalog stays but stops selling. `null` ends holiday mode.'
45
48
  body.attribute :billing_address, :object, as: 'SellerAddressParams' do |billing_address|
46
49
  billing_address.include_attributes Spree::Api::V3::AddressRequestSchema
47
50
  end
@@ -133,8 +136,13 @@ module Spree
133
136
  end
134
137
  end
135
138
 
139
+ # Plus what extensions opened to sellers — never the operator-level
140
+ # list — so fields a plugin adds to the panel's profile form save.
136
141
  def permitted_params
137
- normalize_params(params.permit(*declared_permitted_attributes))
142
+ normalize_params(
143
+ params.permit(*declared_permitted_attributes,
144
+ *Array(Spree::Seller.try(:additional_seller_permitted_attributes)))
145
+ )
138
146
  end
139
147
 
140
148
  private
@@ -13,8 +13,9 @@ module Spree
13
13
 
14
14
  request_params 'ApplyStoreCreditParams', action: :create do |body|
15
15
  body.attribute :amount, :decimal,
16
- example: '10.00',
17
- description: 'Defaults to as much as the cart can use. A JSON number is still read until 6.1, with a deprecation warning.'
16
+ example: '10.00',
17
+ description: 'Defaults to as much as the cart can use. ' \
18
+ 'A JSON number is still read until 6.5, with a deprecation warning.'
18
19
  end
19
20
 
20
21
  # POST /api/v3/store/carts/:cart_id/store_credits
@@ -63,7 +64,10 @@ module Spree
63
64
  def stringify_numeric_amount
64
65
  return unless params[:amount].is_a?(Numeric)
65
66
 
66
- Spree::Deprecation.warn('Sending the store credit amount as a JSON number is deprecated and will be refused in Spree 6.1. Send a decimal string such as "25.00".')
67
+ Spree::Deprecation.warn(
68
+ 'Sending the store credit amount as a JSON number is deprecated and will be refused in Spree 6.5. ' \
69
+ 'Send a decimal string such as "25.00".'
70
+ )
67
71
  params[:amount] = params[:amount].to_s
68
72
  end
69
73
  end
@@ -129,17 +129,20 @@ module Spree
129
129
  end
130
130
  end
131
131
 
132
- # DELETE /api/v3/store/carts/:id
133
- # Deletes/abandons the cart
132
+ # Abandons a cart after checking its completion claim under the row lock.
133
+ #
134
+ # @return [void]
134
135
  def destroy
135
136
  find_cart!
136
137
 
137
- result = Spree.cart_destroy_service.call(cart: @cart)
138
+ with_order_lock do
139
+ result = Spree.cart_destroy_service.call(cart: @cart)
138
140
 
139
- if result.success?
140
- head :no_content
141
- else
142
- render_service_error(result.error.to_s)
141
+ if result.success?
142
+ head :no_content
143
+ else
144
+ render_service_error(result.error.to_s)
145
+ end
143
146
  end
144
147
  end
145
148
 
@@ -213,7 +216,7 @@ module Spree
213
216
  end
214
217
 
215
218
  def model_class
216
- Spree::Order
219
+ Spree::Cart
217
220
  end
218
221
 
219
222
  def serializer_class
@@ -16,7 +16,7 @@ module Spree
16
16
  end
17
17
 
18
18
  # Exclude automatic (rule-based) rows still living in spree_categories
19
- # until the Phase 4 migration moves them to Collections (removed in 6.1).
19
+ # until the Phase 4 migration moves them to Collections (removed in 6.3).
20
20
  def scope
21
21
  super.manual
22
22
  end
@@ -12,7 +12,7 @@ module Spree
12
12
  request_params :company_address do |body|
13
13
  body.include_attributes Spree::Api::V3::AddressRequestSchema
14
14
  body.require_attributes :first_name, :last_name, :address1, :city, :country_code, on: :create
15
- body.attribute :zipcode, :string, deprecated: 'Use `postal_code`. Removed in 6.1.'
15
+ body.attribute :zipcode, :string, deprecated: 'Use `postal_code`. Removed in 6.5.'
16
16
  body.attribute :default_billing, :boolean,
17
17
  permit: false,
18
18
  description: "True makes this the node's default billing address, false gives that up, and leaving it out changes nothing."
@@ -3,9 +3,10 @@ module Spree
3
3
  module V3
4
4
  module Store
5
5
  # Exposes the store the request resolved to, so a storefront can render
6
- # its name and default SEO metadata in the requested locale.
6
+ # its name, branding and default SEO metadata in the requested locale.
7
7
  class StoreController < Store::BaseController
8
- # A gated storefront still needs a page title on its sign-in wall.
8
+ # A gated storefront still needs its name, logo and page metadata on
9
+ # its sign-in wall. Every field here is public by nature.
9
10
  allow_guest_storefront_access!
10
11
 
11
12
  # GET /api/v3/store/store
@@ -12,6 +12,10 @@ module Spree
12
12
  description: 'Per-currency prices. Upserted by currency.'
13
13
  attribute :stock_levels, :array, of: Spree::Api::V3::StockLevelRequestSchema,
14
14
  description: "Stock per location, at this seller's own locations only: a location belonging to anyone else is ignored."
15
+ definition.describe_attribute :options,
16
+ 'One pair per option type the variant takes part in (size, color), naming an option type and ' \
17
+ 'value the marketplace already defines (see `GET /option_types`). A seller cannot add to that ' \
18
+ 'vocabulary, so an unknown name is refused with a 422.'
15
19
  end
16
20
  end
17
21
  end
@@ -22,8 +22,8 @@ module Spree
22
22
  attribute :state_name, :string, description: 'The state name, for countries without predefined states.'
23
23
  attribute :quick_checkout, :boolean,
24
24
  description: 'Relaxes validation (name, phone, postal code, street), for express checkouts that share a partial address.'
25
- attribute :country_iso, :string, deprecated: 'Use `country_code`. Removed in 6.1.'
26
- attribute :state_abbr, :string, deprecated: 'Use `state_code`. Removed in 6.1.'
25
+ attribute :country_iso, :string, deprecated: 'Use `country_code`. Removed in 6.5.'
26
+ attribute :state_abbr, :string, deprecated: 'Use `state_code`. Removed in 6.5.'
27
27
  end
28
28
  end
29
29
  end
@@ -6,10 +6,10 @@ module Spree
6
6
  address1: [:string, nullable: true], address2: [:string, nullable: true],
7
7
  city: [:string, nullable: true], postal_code: [:string, nullable: true], phone: [:string, nullable: true],
8
8
  company: [:string, nullable: true], state_code: [:string, nullable: true],
9
- state_abbr: [:string, nullable: true, deprecated: 'Use `state_code`. Removed in 6.1.'],
9
+ state_abbr: [:string, nullable: true, deprecated: 'Use `state_code`. Removed in 6.5.'],
10
10
  state_name: [:string, nullable: true],
11
11
  state_text: [:string, nullable: true], country_code: [:string, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'],
12
- country_iso: [:string, deprecated: 'Use `country_code`. Removed in 6.1.'],
12
+ country_iso: [:string, deprecated: 'Use `country_code`. Removed in 6.5.'],
13
13
  country_name: :string,
14
14
  quick_checkout: :boolean, is_default_billing: :boolean, is_default_shipping: :boolean,
15
15
  label: [:string, nullable: true], owner: { nullable: true }
@@ -23,7 +23,7 @@ module Spree
23
23
  :state_code, :quick_checkout, :is_default_billing, :is_default_shipping
24
24
 
25
25
  # @deprecated Storefronts shipped against these names; use +state_code+
26
- # and +country_code+. Removed in 6.1.
26
+ # and +country_code+. Removed in 6.5.
27
27
  attribute :state_abbr, &:state_code
28
28
  attribute :country_iso, &:country_code
29
29
 
@@ -3,7 +3,7 @@ module Spree
3
3
  module V3
4
4
  module Admin
5
5
  class AddressSerializer < V3::AddressSerializer
6
- # The Store API keeps these deprecated names until 6.1.
6
+ # The Store API keeps these deprecated names until 6.5.
7
7
  %i[state_abbr country_iso].each { |key| _attributes.delete(key) }
8
8
 
9
9
  typelize customer_id: [:string, nullable: true],
@@ -4,6 +4,10 @@ module Spree
4
4
  module Admin
5
5
  class CompanyMembershipSerializer < V3::CompanyMembershipSerializer
6
6
  attributes created_at: :iso8601, updated_at: :iso8601
7
+
8
+ # The member as a customer, so a list can show their name, not only
9
+ # the email.
10
+ one :customer, resource: proc { Spree.api.admin_customer_serializer }, if: proc { expand?('customer') }
7
11
  end
8
12
  end
9
13
  end
@@ -0,0 +1,30 @@
1
+ module Spree
2
+ module Api
3
+ module V3
4
+ module Admin
5
+ # The diagnostics report (Spree::Diagnostics::Report). A computed
6
+ # value rather than a record, so it carries no id. `errors[].error_class`
7
+ # is an exception's class name on purpose: it is what a maintainer
8
+ # reads in a bug report, not a value any client branches on.
9
+ class DiagnosticsSerializer < V3::BaseSerializer
10
+ typelize generated_at: :string,
11
+ spree_version: :string,
12
+ markdown: :string,
13
+ issue_url: :string,
14
+ issue_prefilled: :boolean,
15
+ sections: 'Array<{ key: string; title: string; rows: Array<{ label: string; value: string }> }>',
16
+ errors: 'Array<{ error_class: string; source: string | null; frames: string[]; ' \
17
+ 'request_id: string | null; count: number; first_seen_at: string; last_seen_at: string }>'
18
+
19
+ _attributes.delete(:id)
20
+
21
+ attributes :spree_version, :sections, :errors, generated_at: :iso8601
22
+
23
+ attribute(:markdown, &:to_markdown)
24
+ attribute(:issue_url, &:issue_url)
25
+ attribute(:issue_prefilled, &:issue_prefilled?)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -28,7 +28,8 @@ module Spree
28
28
  price_list_id: [:string, nullable: true],
29
29
  price_list_name: [:string, nullable: true],
30
30
  catalog_id: [:string, nullable: true],
31
- catalog_name: [:string, nullable: true]
31
+ catalog_name: [:string, nullable: true],
32
+ product_id: [:string, nullable: true]
32
33
 
33
34
  # price_source is operational provenance — admin-only, never on the
34
35
  # store serializer.
@@ -66,6 +67,10 @@ module Spree
66
67
 
67
68
  prefixed_id_attributes :tax_category
68
69
 
70
+ # So an order page can link each line to its product without
71
+ # expanding the variant.
72
+ prefixed_id_attributes :product
73
+
69
74
  # Override inherited associations to use admin serializers
70
75
  many :option_values, resource: proc { Spree.api.admin_option_value_serializer }
71
76
  many :digital_links, resource: proc { Spree.api.admin_digital_link_serializer }
@@ -3,7 +3,7 @@ module Spree
3
3
  module V3
4
4
  module Admin
5
5
  class MarketSerializer < V3::MarketSerializer
6
- # The Store API keeps this deprecated name until 6.1.
6
+ # The Store API keeps this deprecated name until 6.5.
7
7
  _attributes.delete(:country_isos)
8
8
 
9
9
  typelize tax_provider: [:string, nullable: true, comment: 'Tax provider; null uses the store default. Built-in: internal. Provider gems register more.']
@@ -3,7 +3,7 @@ module Spree
3
3
  module V3
4
4
  module Admin
5
5
  class RefundSerializer < V3::RefundSerializer
6
- # The Store API keeps this deprecated name until 6.1.
6
+ # The Store API keeps this deprecated name until 6.5.
7
7
  _attributes.delete(:reimbursement_id)
8
8
 
9
9
  typelize payment_id: [:string, nullable: true],
@@ -55,6 +55,11 @@ module Spree
55
55
  # so the minimum-products requirement asks the same question free.
56
56
  attributes :products_count
57
57
 
58
+ # What is live and what waits on the operator's review, read in the
59
+ # same query as the total above.
60
+ typelize(Spree::Product::ALL_STATUSES.to_h { |status| [status.to_sym, :number] })
61
+ attribute :products_count_by_status, &:products_count_by_status
62
+
58
63
  attributes :users_count
59
64
 
60
65
  # How far through the marketplace's checklist this seller is — what
@@ -78,6 +83,11 @@ module Spree
78
83
  resource: proc { Spree.api.admin_address_serializer },
79
84
  if: proc { |seller| seller.returns_address.present? }
80
85
 
86
+ # The stock location the returns address is read from. The address
87
+ # is not the seller's own to write — it is edited on this location.
88
+ typelize returns_location_id: [:string, nullable: true]
89
+ prefixed_id_attributes :returns_location
90
+
81
91
  expandable_custom_fields admin: true
82
92
  end
83
93
  end
@@ -3,7 +3,7 @@ module Spree
3
3
  module V3
4
4
  module Admin
5
5
  class StockLocationSerializer < V3::StockLocationSerializer
6
- # The Store API keeps these deprecated names until 6.1.
6
+ # The Store API keeps these deprecated names until 6.5.
7
7
  %i[country_iso state_abbr].each { |key| _attributes.delete(key) }
8
8
 
9
9
  include Concerns::ExternalReferencesAttribute
@@ -9,10 +9,8 @@ module Spree
9
9
  supported_currencies: [:string, multi: true, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
10
10
  supported_locales: [:string, multi: true, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],
11
11
  available_locales: [:string, multi: true, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],
12
- logo_url: [:string, nullable: true],
13
12
  mailer_logo_url: [:string, nullable: true],
14
13
  mail_from_address: [:string, nullable: true],
15
- customer_support_email: [:string, nullable: true],
16
14
  new_order_notifications_email: [:string, nullable: true],
17
15
  order_routing_strategy: [:string, comment: 'Order routing strategy. Built-in: rules. Extensions may register more.'],
18
16
  payout_provider: [:string, nullable: true, comment: 'Payout provider; null uses the installation default. Built-in: system. Provider gems register more (e.g. stripe).'],
@@ -25,7 +23,6 @@ module Spree
25
23
  :default_locale,
26
24
  :default_country_code,
27
25
  :mail_from_address,
28
- :customer_support_email,
29
26
  :new_order_notifications_email,
30
27
  created_at: :iso8601, updated_at: :iso8601
31
28
 
@@ -78,10 +75,6 @@ module Spree
78
75
  Spree::Locales::ALL
79
76
  end
80
77
 
81
- attribute :logo_url do |store|
82
- image_url_for(store.logo)
83
- end
84
-
85
78
  attribute :mailer_logo_url do |store|
86
79
  image_url_for(store.mailer_logo)
87
80
  end
@@ -82,7 +82,7 @@ module Spree
82
82
  amount = name.to_s.delete_prefix('display_')
83
83
  [:string, nullable: nullable,
84
84
  comment: "`#{amount}` formatted with its currency symbol in the request's language.",
85
- deprecated: "Format `#{amount}` with its currency instead. Removed in 6.1."]
85
+ deprecated: "Format `#{amount}` with its currency instead. Removed in 6.5."]
86
86
  end
87
87
 
88
88
  # Declares rates and percentages, written as decimal strings without
@@ -4,7 +4,8 @@ module Spree
4
4
  # Store API Cart Serializer
5
5
  # Pre-purchase cart data with checkout progression info
6
6
  class CartSerializer < BaseSerializer
7
- typelize number: [:string, deprecated: 'Use `id`; a cart has no order number. Removed in 6.1.'], current_step: :string, completed_steps: 'string[]', token: :string,
7
+ typelize number: [:string, deprecated: 'Use `id`; a cart has no order number. Removed in 6.5.'],
8
+ current_step: :string, completed_steps: 'string[]', token: :string,
8
9
  email: [:string, nullable: true], customer_note: [:string, nullable: true],
9
10
  market_id: [:string, nullable: true], channel_id: [:string, nullable: true], currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
10
11
  locale: [:string, nullable: true, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'], total_quantity: :number, coupon_code: [:string, nullable: true],
@@ -52,7 +53,7 @@ module Spree
52
53
  end
53
54
 
54
55
  # @deprecated `number` mirrors `id` (carts have no order-style
55
- # number) — kept one release for 5.x clients; removed in 6.1.
56
+ # number) — kept until 6.5 for 5.x clients.
56
57
  attributes :number, :token, :email, :customer_note, :po_number,
57
58
  :currency, :locale, :total_quantity, :warnings, :coupon_code
58
59
 
@@ -75,7 +76,7 @@ module Spree
75
76
  # with its numbers stripped tells them nothing they can act on.
76
77
  attribute :requirements do |order|
77
78
  # 5.6 storefronts matched the delivery requirement by its field, so
78
- # it keeps the old name until 6.1; `code` already carries the new one.
79
+ # it keeps the old name until 6.5; `code` already carries the new one.
79
80
  requirements = Spree::Checkout::Requirements.new(order).call.map do |requirement|
80
81
  requirement[:field] == 'delivery_method' ? requirement.merge(field: 'shipping_method') : requirement
81
82
  end
@@ -6,7 +6,7 @@ module Spree
6
6
  include Typelizer::DSL
7
7
 
8
8
  typelize iso: [:string, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'], iso3: :string,
9
- name: [:string, deprecated: 'Name the country from `iso` with `Intl.DisplayNames` (type `region`). Removed in 6.1.'],
9
+ name: [:string, deprecated: 'Name the country from `iso` with `Intl.DisplayNames` (type `region`). Removed in 6.5.'],
10
10
  states_required: :boolean, zipcode_required: :boolean,
11
11
  market: [:Market, nullable: true]
12
12
 
@@ -5,8 +5,9 @@ module Spree
5
5
  include Alba::Resource
6
6
  include Typelizer::DSL
7
7
 
8
- typelize iso_code: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'], name: [:string, deprecated: 'Name the currency from `iso_code` with `Intl.DisplayNames` (type `currency`). Removed in 6.1.'],
9
- symbol: [:string, deprecated: 'Format amounts with `formatMoney` or `Intl.NumberFormat`, which place the symbol. Removed in 6.1.'],
8
+ typelize iso_code: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
9
+ name: [:string, deprecated: 'Name the currency from `iso_code` with `Intl.DisplayNames` (type `currency`). Removed in 6.5.'],
10
+ symbol: [:string, deprecated: 'Format amounts with `formatMoney` or `Intl.NumberFormat`, which place the symbol. Removed in 6.5.'],
10
11
  decimal_places: :number
11
12
 
12
13
  attributes :iso_code, :name, :symbol
@@ -8,7 +8,7 @@ module Spree
8
8
  include Typelizer::DSL
9
9
 
10
10
  typelize code: [:string, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],
11
- name: [:string, deprecated: 'Name the locale from `code` with `Intl.DisplayNames`. Removed in 6.1.'],
11
+ name: [:string, deprecated: 'Name the locale from `code` with `Intl.DisplayNames`. Removed in 6.5.'],
12
12
  default: :boolean, rtl: :boolean
13
13
 
14
14
  attributes :code, :name
@@ -6,14 +6,14 @@ module Spree
6
6
  default_locale: [:string, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],
7
7
  supported_locales: [:string, multi: true, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],
8
8
  country_codes: [:string, multi: true, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'],
9
- country_isos: [:string, multi: true, deprecated: 'Use `country_codes`. Removed in 6.1.'],
9
+ country_isos: [:string, multi: true, deprecated: 'Use `country_codes`. Removed in 6.5.'],
10
10
  tax_inclusive: :boolean,
11
11
  default: :boolean
12
12
 
13
13
  attributes :name, :currency, :default_locale, :tax_inclusive, :default, :country_codes
14
14
 
15
15
  # @deprecated Storefronts shipped against this name; use +country_codes+.
16
- # Removed in 6.1.
16
+ # Removed in 6.5.
17
17
  attribute :country_isos, &:country_codes
18
18
 
19
19
  attribute :supported_locales do |market|
@@ -7,7 +7,7 @@ module Spree
7
7
  typelize display_amount: display_money_type(:display_amount, nullable: false),
8
8
  currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
9
9
  recorded_at: :string,
10
- amount_in_cents: [:number, nullable: true, deprecated: 'Use `amount`. Removed in 6.1.']
10
+ amount_in_cents: [:number, nullable: true, deprecated: 'Use `amount`. Removed in 6.5.']
11
11
 
12
12
  attributes :currency
13
13
 
@@ -9,8 +9,8 @@ module Spree
9
9
  display_compare_at_amount: display_money_type(:display_compare_at_amount),
10
10
  currency: [:string, nullable: true, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
11
11
  price_list_id: [:string, nullable: true],
12
- amount_in_cents: [:number, nullable: true, deprecated: 'Use `amount`. Removed in 6.1.'],
13
- compare_at_amount_in_cents: [:number, nullable: true, deprecated: 'Use `compare_at_amount`. Removed in 6.1.']
12
+ amount_in_cents: [:number, nullable: true, deprecated: 'Use `amount`. Removed in 6.5.'],
13
+ compare_at_amount_in_cents: [:number, nullable: true, deprecated: 'Use `compare_at_amount`. Removed in 6.5.']
14
14
 
15
15
  attributes :currency
16
16
 
@@ -0,0 +1,26 @@
1
+ module Spree
2
+ module Api
3
+ module V3
4
+ class ProductCategorySerializer < BaseSerializer
5
+ typelize product_id: [:string, nullable: true],
6
+ category_id: [:string, nullable: true]
7
+
8
+ attribute :product_id do |product_category|
9
+ prefixed_id_for(Spree::Product, product_category.product_id)
10
+ end
11
+
12
+ attribute :category_id do |product_category|
13
+ prefixed_id_for(Spree::Category, product_category.category_id)
14
+ end
15
+
16
+ private
17
+
18
+ def prefixed_id_for(klass, id)
19
+ return nil if id.nil?
20
+
21
+ "#{klass._prefix_id_prefix}_#{Spree::PrefixedId::SQIDS.encode([id])}"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Spree
2
+ module Api
3
+ module V3
4
+ class ProductCollectionSerializer < BaseSerializer
5
+ typelize product_id: [:string, nullable: true],
6
+ collection_id: [:string, nullable: true]
7
+
8
+ attribute :product_id do |product_collection|
9
+ prefixed_id_for(Spree::Product, product_collection.product_id)
10
+ end
11
+
12
+ attribute :collection_id do |product_collection|
13
+ prefixed_id_for(Spree::Collection, product_collection.collection_id)
14
+ end
15
+
16
+ private
17
+
18
+ def prefixed_id_for(klass, id)
19
+ return nil if id.nil?
20
+
21
+ "#{klass._prefix_id_prefix}_#{Spree::PrefixedId::SQIDS.encode([id])}"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -7,7 +7,7 @@ module Spree
7
7
  typelize transaction_id: [:string, nullable: true],
8
8
  payment_id: [:string, nullable: true], refund_reason_id: [:string, nullable: true],
9
9
  originator_id: [:string, nullable: true], originator_type: [:string, nullable: true],
10
- reimbursement_id: [:string, nullable: true, deprecated: 'Always null: reimbursements are gone. Use `originator_id`. Removed in 6.1.']
10
+ reimbursement_id: [:string, nullable: true, deprecated: 'Always null: reimbursements are gone. Use `originator_id`. Removed in 6.5.']
11
11
 
12
12
  attributes :transaction_id
13
13
 
@@ -24,7 +24,7 @@ module Spree
24
24
  end
25
25
 
26
26
  # @deprecated Reimbursements were folded into returns, which a refund
27
- # names as its +originator+. Removed in 6.1.
27
+ # names as its +originator+. Removed in 6.5.
28
28
  attribute(:reimbursement_id) { nil }
29
29
  end
30
30
  end
@@ -3,7 +3,7 @@ module Spree
3
3
  module V3
4
4
  module Seller
5
5
  class AddressSerializer < V3::AddressSerializer
6
- # The Store API keeps these deprecated names until 6.1. A seller
6
+ # The Store API keeps these deprecated names until 6.5. A seller
7
7
  # keeps no address book of the buyer's, so has no owner to read.
8
8
  %i[state_abbr country_iso owner].each { |key| _attributes.delete(key) }
9
9
  end
@@ -0,0 +1,18 @@
1
+ module Spree
2
+ module Api
3
+ module V3
4
+ module Seller
5
+ # An option type as a seller builds variants from it: its name and,
6
+ # when expanded, the values a variant may take.
7
+ #
8
+ # The store shape plus its values, and nothing the operator keeps to
9
+ # maintain the vocabulary — no `metadata`, `filterable` or timestamps.
10
+ class OptionTypeSerializer < V3::OptionTypeSerializer
11
+ many :option_values,
12
+ resource: proc { Spree.api.option_value_serializer },
13
+ if: proc { expand?('option_values') }
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end