spree_api 6.0.0.rc7 → 6.0.1

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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/spree/api/v3/admin/maintenance_tasks_switch.rb +35 -0
  3. data/app/controllers/spree/api/v3/admin/invitation_acceptances_controller.rb +8 -4
  4. data/app/controllers/spree/api/v3/admin/maintenance_task_runs/cancellations_controller.rb +42 -0
  5. data/app/controllers/spree/api/v3/admin/maintenance_task_runs_controller.rb +92 -0
  6. data/app/controllers/spree/api/v3/admin/sellers_controller.rb +1 -1
  7. data/app/controllers/spree/api/v3/admin/store_controller.rb +23 -7
  8. data/app/controllers/spree/api/v3/admin/upgrade_steps_controller.rb +114 -0
  9. data/app/controllers/spree/api/v3/seller/invitation_acceptances_controller.rb +15 -5
  10. data/app/controllers/spree/api/v3/store/customers_controller.rb +1 -0
  11. data/app/controllers/spree/api/v3/store/store_controller.rb +25 -0
  12. data/app/serializers/spree/api/v3/address_serializer.rb +2 -0
  13. data/app/serializers/spree/api/v3/admin/address_serializer.rb +2 -0
  14. data/app/serializers/spree/api/v3/admin/category_serializer.rb +1 -3
  15. data/app/serializers/spree/api/v3/admin/claim_serializer.rb +2 -0
  16. data/app/serializers/spree/api/v3/admin/collection_serializer.rb +1 -4
  17. data/app/serializers/spree/api/v3/admin/company_serializer.rb +2 -0
  18. data/app/serializers/spree/api/v3/admin/credit_card_serializer.rb +2 -0
  19. data/app/serializers/spree/api/v3/admin/customer_serializer.rb +2 -0
  20. data/app/serializers/spree/api/v3/admin/delivery_method_serializer.rb +2 -0
  21. data/app/serializers/spree/api/v3/admin/fulfillment_serializer.rb +1 -0
  22. data/app/serializers/spree/api/v3/admin/gift_card_serializer.rb +2 -0
  23. data/app/serializers/spree/api/v3/admin/invitation_serializer.rb +1 -1
  24. data/app/serializers/spree/api/v3/admin/line_item_serializer.rb +1 -0
  25. data/app/serializers/spree/api/v3/admin/maintenance_task_run_serializer.rb +72 -0
  26. data/app/serializers/spree/api/v3/admin/media_serializer.rb +2 -0
  27. data/app/serializers/spree/api/v3/admin/newsletter_subscriber_serializer.rb +2 -0
  28. data/app/serializers/spree/api/v3/admin/option_type_serializer.rb +2 -0
  29. data/app/serializers/spree/api/v3/admin/option_value_serializer.rb +2 -0
  30. data/app/serializers/spree/api/v3/admin/order_serializer.rb +2 -0
  31. data/app/serializers/spree/api/v3/admin/payment_method_serializer.rb +2 -0
  32. data/app/serializers/spree/api/v3/admin/payment_serializer.rb +3 -1
  33. data/app/serializers/spree/api/v3/admin/payment_source_serializer.rb +2 -0
  34. data/app/serializers/spree/api/v3/admin/product_serializer.rb +1 -3
  35. data/app/serializers/spree/api/v3/admin/return_serializer.rb +2 -0
  36. data/app/serializers/spree/api/v3/admin/seller_payout_serializer.rb +2 -1
  37. data/app/serializers/spree/api/v3/admin/seller_serializer.rb +4 -0
  38. data/app/serializers/spree/api/v3/admin/store_credit_serializer.rb +2 -0
  39. data/app/serializers/spree/api/v3/admin/store_serializer.rb +3 -4
  40. data/app/serializers/spree/api/v3/admin/variant_serializer.rb +1 -3
  41. data/app/serializers/spree/api/v3/base_serializer.rb +28 -0
  42. data/app/serializers/spree/api/v3/category_serializer.rb +1 -4
  43. data/app/serializers/spree/api/v3/claim_serializer.rb +2 -0
  44. data/app/serializers/spree/api/v3/collection_serializer.rb +1 -4
  45. data/app/serializers/spree/api/v3/company_serializer.rb +2 -0
  46. data/app/serializers/spree/api/v3/credit_card_serializer.rb +2 -0
  47. data/app/serializers/spree/api/v3/customer_serializer.rb +2 -0
  48. data/app/serializers/spree/api/v3/delivery_method_serializer.rb +2 -0
  49. data/app/serializers/spree/api/v3/fulfillment_serializer.rb +2 -0
  50. data/app/serializers/spree/api/v3/gift_card_serializer.rb +1 -0
  51. data/app/serializers/spree/api/v3/line_item_serializer.rb +2 -0
  52. data/app/serializers/spree/api/v3/media_serializer.rb +2 -0
  53. data/app/serializers/spree/api/v3/newsletter_subscriber_serializer.rb +2 -0
  54. data/app/serializers/spree/api/v3/option_type_serializer.rb +2 -0
  55. data/app/serializers/spree/api/v3/option_value_serializer.rb +2 -0
  56. data/app/serializers/spree/api/v3/order_serializer.rb +2 -0
  57. data/app/serializers/spree/api/v3/payment_method_serializer.rb +2 -0
  58. data/app/serializers/spree/api/v3/payment_serializer.rb +3 -1
  59. data/app/serializers/spree/api/v3/payment_source_serializer.rb +2 -0
  60. data/app/serializers/spree/api/v3/product_serializer.rb +1 -4
  61. data/app/serializers/spree/api/v3/return_serializer.rb +2 -0
  62. data/app/serializers/spree/api/v3/seller/invitation_serializer.rb +22 -1
  63. data/app/serializers/spree/api/v3/seller/profile_serializer.rb +1 -1
  64. data/app/serializers/spree/api/v3/seller_serializer.rb +2 -0
  65. data/app/serializers/spree/api/v3/store_credit_serializer.rb +2 -0
  66. data/app/serializers/spree/api/v3/store_serializer.rb +16 -0
  67. data/app/serializers/spree/api/v3/variant_serializer.rb +1 -4
  68. data/app/services/spree/api/v3/request_schema.rb +15 -7
  69. data/config/routes.rb +14 -2
  70. data/lib/spree/api/dependencies.rb +2 -1
  71. data/lib/spree/api/enum_types.rb +2 -1
  72. data/lib/typelizer/open_enums.rb +21 -2
  73. metadata +13 -6
@@ -0,0 +1,72 @@
1
+ module Spree
2
+ module Api
3
+ module V3
4
+ module Admin
5
+ # Admin API serializer for {Spree::MaintenanceTaskRun} — the progress
6
+ # the dashboard polls while a task runs, and the audit trail it shows
7
+ # afterwards (docs/plans/6.0-maintenance-tasks.md).
8
+ #
9
+ # Admin-only by design: there is no store counterpart, because nothing
10
+ # about operator-run data work is customer-facing.
11
+ class MaintenanceTaskRunSerializer < BaseSerializer
12
+ typelize task_name: :string,
13
+ status: [:string, enum: Spree::MaintenanceTaskRun.statuses, enum_type_name: 'MaintenanceTaskRunStatus'],
14
+ dry_run: :boolean,
15
+ initiated_via: :string,
16
+ tick_count: :number,
17
+ tick_total: [:number, nullable: true],
18
+ duration: [:number, nullable: true],
19
+ tallies: 'Record<string, number>',
20
+ arguments: 'Record<string, unknown>',
21
+ error_class: [:string, nullable: true],
22
+ error_message: [:string, nullable: true],
23
+ error_backtrace: [:string, nullable: true],
24
+ active: :boolean,
25
+ admin_user_id: [:string, nullable: true],
26
+ started_at: [:string, nullable: true],
27
+ ended_at: [:string, nullable: true]
28
+
29
+ attributes :status, :dry_run, :initiated_via,
30
+ :tick_count, :tick_total, :error_class, :error_message,
31
+ :started_at, :ended_at, :created_at, :updated_at
32
+
33
+ # The task's short name, as `GET /upgrade_steps` gives it.
34
+ attribute :task_name, &:task_api_type
35
+
36
+ # to_f before rounding: the column is a decimal, and a BigDecimal
37
+ # serializes as a quoted string — a client reading `duration` wants a
38
+ # number, and the schema says it gets one.
39
+ attribute :duration do |run|
40
+ run.duration&.to_f&.round(3)
41
+ end
42
+
43
+ attribute :tallies do |run|
44
+ run.tallies || {}
45
+ end
46
+
47
+ attribute :arguments do |run|
48
+ run.arguments || {}
49
+ end
50
+
51
+ # The failure detail an operator needs to fix the cause. Held back
52
+ # from read-only callers — a backtrace names internal paths and
53
+ # class names that a read scope has no business seeing.
54
+ attribute :error_backtrace do |run|
55
+ run.error_backtrace if params[:show_backtrace]
56
+ end
57
+
58
+ attribute :active, &:active?
59
+
60
+ attribute :admin_user_id do |run|
61
+ run.admin_user&.prefixed_id
62
+ end
63
+
64
+ # Who fired it. Pass `expand=admin_user` for the record itself.
65
+ one :admin_user,
66
+ resource: proc { Spree.api.admin_admin_user_serializer },
67
+ if: proc { expand?('admin_user') }
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -86,6 +86,8 @@ module Spree
86
86
  attribute :viewable_type do |asset|
87
87
  Spree::Base.polymorphic_api_type(asset.viewable_type)
88
88
  end
89
+
90
+ expandable_custom_fields admin: true
89
91
  end
90
92
  end
91
93
  end
@@ -9,6 +9,8 @@ module Spree
9
9
  # customer-facing serializer so public fields stay in sync.
10
10
  class NewsletterSubscriberSerializer < V3::NewsletterSubscriberSerializer
11
11
  prefixed_id_attributes :customer
12
+
13
+ expandable_custom_fields admin: true
12
14
  end
13
15
  end
14
16
  end
@@ -13,6 +13,8 @@ module Spree
13
13
  many :option_values,
14
14
  resource: proc { Spree.api.admin_option_value_serializer },
15
15
  if: proc { expand?('option_values') }
16
+
17
+ expandable_custom_fields admin: true
16
18
  end
17
19
  end
18
20
  end
@@ -11,6 +11,8 @@ module Spree
11
11
  one :option_type,
12
12
  resource: proc { Spree.api.admin_option_type_serializer },
13
13
  if: proc { expand?('option_type') }
14
+
15
+ expandable_custom_fields admin: true
14
16
  end
15
17
  end
16
18
  end
@@ -198,6 +198,8 @@ module Spree
198
198
  typelize freight_summary: [:FreightSummary, nullable: true]
199
199
 
200
200
  one :freight_summary, resource: proc { Spree.api.admin_freight_summary_serializer }
201
+
202
+ expandable_custom_fields admin: true
201
203
  end
202
204
  end
203
205
  end
@@ -25,6 +25,8 @@ module Spree
25
25
  attribute(:logo_url) { |payment_method| payment_method.class.logo_url }
26
26
  attribute(:docs_url) { |payment_method| payment_method.class.docs_url }
27
27
  attribute(:third_party) { |payment_method| payment_method.class.third_party? }
28
+
29
+ expandable_custom_fields admin: true
28
30
  end
29
31
  end
30
32
  end
@@ -45,7 +45,7 @@ module Spree
45
45
  Spree.api.admin_payment_source_serializer
46
46
  end
47
47
 
48
- serializer.new(payment.source).to_h
48
+ serializer.new(payment.source, params: nested_params('source')).to_h
49
49
  end
50
50
 
51
51
  many :capture_events,
@@ -65,6 +65,8 @@ module Spree
65
65
  many :payment_splits,
66
66
  resource: proc { Spree.api.admin_payment_split_serializer },
67
67
  if: proc { expand?('payment_splits') }
68
+
69
+ expandable_custom_fields admin: true
68
70
  end
69
71
  end
70
72
  end
@@ -7,6 +7,8 @@ module Spree
7
7
 
8
8
  attributes :metadata,
9
9
  created_at: :iso8601, updated_at: :iso8601
10
+
11
+ expandable_custom_fields admin: true
10
12
  end
11
13
  end
12
14
  end
@@ -108,9 +108,7 @@ module Spree
108
108
  resource: proc { Spree.api.admin_collection_serializer },
109
109
  if: proc { expand?('collections') }
110
110
 
111
- many :custom_fields,
112
- resource: proc { Spree.api.admin_custom_field_serializer },
113
- if: proc { expand?('custom_fields') }
111
+ expandable_custom_fields admin: true
114
112
 
115
113
  many :product_publications,
116
114
  resource: proc { Spree.api.admin_product_publication_serializer },
@@ -49,6 +49,8 @@ module Spree
49
49
 
50
50
  # Where the inbound parcel is, as the carrier last reported it.
51
51
  many :deliveries, resource: proc { Spree.api.admin_delivery_serializer }
52
+
53
+ expandable_custom_fields admin: true
52
54
  end
53
55
  end
54
56
  end
@@ -17,7 +17,8 @@ module Spree
17
17
  reference: 'string | null',
18
18
  period_start: 'string | null',
19
19
  period_end: 'string | null',
20
- transfers_count: :number
20
+ transfers_count: :number,
21
+ metadata: 'Record<string, unknown>'
21
22
 
22
23
  attributes :status, :currency, :reference, :metadata,
23
24
  period_start: :iso8601, period_end: :iso8601,
@@ -6,6 +6,8 @@ module Spree
6
6
  # shopper also gets, plus the operational state and the settlement and
7
7
  # tax configuration only the operator sets.
8
8
  class SellerSerializer < V3::SellerSerializer
9
+ include Concerns::ExternalReferencesAttribute
10
+
9
11
  typelize status: [:string, enum: Spree::Seller.statuses, enum_type_name: 'SellerStatus'],
10
12
  legal_name: [:string, nullable: true],
11
13
  registration_number: [:string, nullable: true],
@@ -75,6 +77,8 @@ module Spree
75
77
  one :returns_address,
76
78
  resource: proc { Spree.api.admin_address_serializer },
77
79
  if: proc { |seller| seller.returns_address.present? }
80
+
81
+ expandable_custom_fields admin: true
78
82
  end
79
83
  end
80
84
  end
@@ -52,6 +52,8 @@ module Spree
52
52
  one :customer,
53
53
  resource: proc { Spree.api.admin_customer_serializer },
54
54
  if: proc { expand?('customer') }
55
+
56
+ expandable_custom_fields admin: true
55
57
  end
56
58
  end
57
59
  end
@@ -2,10 +2,10 @@ module Spree
2
2
  module Api
3
3
  module V3
4
4
  module Admin
5
- class StoreSerializer < V3::BaseSerializer
6
- typelize name: :string, url: :string, code: :string, api_url: :string,
5
+ class StoreSerializer < V3::StoreSerializer
6
+ typelize url: :string, code: :string, api_url: :string,
7
7
  default_currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'], default_locale: [:string, enum: Spree::Locales::ALL, enum_type_name: 'LocaleCode'],
8
- default_country_code: [:string, nullable: true],
8
+ default_country_code: [:string, nullable: true, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'],
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'],
@@ -20,7 +20,6 @@ module Spree
20
20
  metadata: 'Record<string, unknown>'
21
21
 
22
22
  attributes :metadata,
23
- :name,
24
23
  :code,
25
24
  :default_currency,
26
25
  :default_locale,
@@ -112,9 +112,7 @@ module Spree
112
112
  resource: proc { Spree.api.admin_price_serializer },
113
113
  if: proc { expand?('prices') }
114
114
 
115
- many :custom_fields,
116
- resource: proc { Spree.api.admin_custom_field_serializer },
117
- if: proc { expand?('custom_fields') }
115
+ expandable_custom_fields admin: true
118
116
 
119
117
  many :stock_levels,
120
118
  resource: proc { Spree.api.admin_stock_level_serializer },
@@ -152,6 +152,12 @@ module Spree
152
152
  }.freeze
153
153
  private_constant :PREFERENCE_LIST_NAMES
154
154
 
155
+ # Settings declared with a code format share the code list request
156
+ # bodies take, so a value read back is the type a write takes.
157
+ FORMAT_CODE_LISTS = { 'iso-country' => :country, 'currency' => :currency, 'locale' => :locale,
158
+ 'timezone' => :time_zone }.freeze
159
+ private_constant :FORMAT_CODE_LISTS
160
+
155
161
  def self.preference_type_hint(schema, name)
156
162
  types = Array(schema['type'])
157
163
  options = {}
@@ -165,6 +171,9 @@ module Spree
165
171
  if schema['enum']
166
172
  options[:enum] = schema['enum'].compact
167
173
  options[:enum_type_name] = PREFERENCE_LIST_NAMES[name.to_sym] if PREFERENCE_LIST_NAMES.key?(name.to_sym)
174
+ elsif (code_list = FORMAT_CODE_LISTS[(schema['items'] || schema)['format']])
175
+ options[:enum_type_name], values = Spree::Api::V3::RequestSchema::CODE_LISTS.fetch(code_list)
176
+ options[:enum] = values.call
168
177
  end
169
178
  options.empty? ? hint : [hint, options]
170
179
  end
@@ -192,6 +201,25 @@ module Spree
192
201
  end
193
202
  end
194
203
 
204
+ # Declares the opt-in `custom_fields` expand. The Store API sends only
205
+ # values whose definition is storefront visible; Admin API serializers
206
+ # pass `admin: true` to send every value.
207
+ #
208
+ # @param admin [Boolean] whether to send every value rather than only storefront visible ones
209
+ # @return [void]
210
+ def self.expandable_custom_fields(admin: false)
211
+ if admin
212
+ many :custom_fields,
213
+ resource: proc { Spree.api.admin_custom_field_serializer },
214
+ if: proc { expand?('custom_fields') }
215
+ else
216
+ many :storefront_custom_fields,
217
+ key: :custom_fields,
218
+ resource: proc { Spree.api.custom_field_serializer },
219
+ if: proc { expand?('custom_fields') }
220
+ end
221
+ end
222
+
195
223
  # Plain decimal notation. BigDecimal renders 0.06 as "0.6e-1", which
196
224
  # is what a client would otherwise print beside a unit.
197
225
  #
@@ -50,10 +50,7 @@ module Spree
50
50
  resource: proc { Spree.api.category_serializer },
51
51
  if: proc { expand?('ancestors') }
52
52
 
53
- many :storefront_custom_fields,
54
- key: :custom_fields,
55
- resource: proc { Spree.api.custom_field_serializer },
56
- if: proc { expand?('custom_fields') }
53
+ expandable_custom_fields
57
54
  end
58
55
  end
59
56
  end
@@ -42,6 +42,8 @@ module Spree
42
42
  many :claim_line_items,
43
43
  resource: proc { Spree.api.claim_line_item_serializer },
44
44
  if: proc { expand?('claim_line_items') }
45
+
46
+ expandable_custom_fields
45
47
  end
46
48
  end
47
49
  end
@@ -29,10 +29,7 @@ module Spree
29
29
  image_url_for(collection.square_image)
30
30
  end
31
31
 
32
- many :storefront_custom_fields,
33
- key: :custom_fields,
34
- resource: proc { Spree.api.custom_field_serializer },
35
- if: proc { expand?('custom_fields') }
32
+ expandable_custom_fields
36
33
  end
37
34
  end
38
35
  end
@@ -25,6 +25,8 @@ module Spree
25
25
  { 'id' => node.prefixed_id, 'name' => node.name, 'kind' => node.kind }
26
26
  end
27
27
  end
28
+
29
+ expandable_custom_fields
28
30
  end
29
31
  end
30
32
  end
@@ -7,6 +7,8 @@ module Spree
7
7
  gateway_payment_profile_id: [:string, nullable: true]
8
8
 
9
9
  attributes :brand, :last4, :month, :year, :name, :default, :gateway_payment_profile_id
10
+
11
+ expandable_custom_fields
10
12
  end
11
13
  end
12
14
  end
@@ -54,6 +54,8 @@ module Spree
54
54
  many :customer_groups,
55
55
  proc { |groups, params| groups.for_store(params&.dig(:store) || Spree::Current.store) },
56
56
  resource: proc { Spree.api.customer_group_serializer }
57
+
58
+ expandable_custom_fields
57
59
  end
58
60
  end
59
61
  end
@@ -15,6 +15,8 @@ module Spree
15
15
  attribute :digital, &:digital?
16
16
  attribute :pickup, &:pickup?
17
17
  attribute :pickup_point, &:pickup_point?
18
+
19
+ expandable_custom_fields
18
20
  end
19
21
  end
20
22
  end
@@ -59,6 +59,8 @@ module Spree
59
59
  one :stock_location, resource: proc { Spree.api.stock_location_serializer }
60
60
  many :delivery_rates, resource: proc { Spree.api.delivery_rate_serializer }
61
61
  many :tax_lines, resource: proc { Spree.api.tax_line_serializer }, if: proc { expand?('tax_lines') }
62
+
63
+ expandable_custom_fields
62
64
  end
63
65
  end
64
66
  end
@@ -51,6 +51,7 @@ module Spree
51
51
 
52
52
  attribute :active, &:active?
53
53
 
54
+ expandable_custom_fields
54
55
  end
55
56
  end
56
57
  end
@@ -73,6 +73,8 @@ module Spree
73
73
  # exactly-one-adjustable rule makes the nested view complete, and the
74
74
  # owner already carries the tax totals.
75
75
  many :tax_lines, resource: proc { Spree.api.tax_line_serializer }, if: proc { expand?('tax_lines') }
76
+
77
+ expandable_custom_fields
76
78
  end
77
79
  end
78
80
  end
@@ -99,6 +99,8 @@ module Spree
99
99
  def url_helpers
100
100
  Rails.application.routes.url_helpers
101
101
  end
102
+
103
+ expandable_custom_fields
102
104
  end
103
105
  end
104
106
  end
@@ -21,6 +21,8 @@ module Spree
21
21
  attribute :customer_id do |subscriber|
22
22
  subscriber.customer&.prefixed_id if current_user && subscriber.customer_id == current_user.id
23
23
  end
24
+
25
+ expandable_custom_fields
24
26
  end
25
27
  end
26
28
  end
@@ -5,6 +5,8 @@ module Spree
5
5
  typelize name: :string, label: :string, position: :number, kind: [:string, enum: Spree::OptionType::KINDS, enum_type_name: 'OptionTypeKind']
6
6
 
7
7
  attributes :name, :label, :position, :kind
8
+
9
+ expandable_custom_fields
8
10
  end
9
11
  end
10
12
  end
@@ -21,6 +21,8 @@ module Spree
21
21
  attribute :image_url do |option_value|
22
22
  image_url_for(option_value.image)
23
23
  end
24
+
25
+ expandable_custom_fields
24
26
  end
25
27
  end
26
28
  end
@@ -79,6 +79,8 @@ module Spree
79
79
  one :shipping_address, resource: proc { Spree.api.address_serializer }
80
80
  one :gift_card, resource: proc { Spree.api.gift_card_serializer }
81
81
  one :market, resource: proc { Spree.api.market_serializer }
82
+
83
+ expandable_custom_fields
82
84
  end
83
85
  end
84
86
  end
@@ -14,6 +14,8 @@ module Spree
14
14
  attribute :session_required, &:session_required?
15
15
 
16
16
  attribute :source_required, &:source_required?
17
+
18
+ expandable_custom_fields
17
19
  end
18
20
  end
19
21
  end
@@ -42,10 +42,12 @@ module Spree
42
42
  Spree.api.payment_source_serializer
43
43
  end
44
44
 
45
- serializer.new(payment.source).to_h
45
+ serializer.new(payment.source, params: nested_params('source')).to_h
46
46
  end
47
47
 
48
48
  one :payment_method, resource: proc { Spree.api.payment_method_serializer }
49
+
50
+ expandable_custom_fields
49
51
  end
50
52
  end
51
53
  end
@@ -5,6 +5,8 @@ module Spree
5
5
  typelize gateway_payment_profile_id: [:string, nullable: true]
6
6
 
7
7
  attributes :gateway_payment_profile_id
8
+
9
+ expandable_custom_fields
8
10
  end
9
11
  end
10
12
  end
@@ -137,10 +137,7 @@ module Spree
137
137
  resource: proc { Spree.api.category_serializer },
138
138
  if: proc { expand?('categories') }
139
139
 
140
- many :storefront_custom_fields,
141
- key: :custom_fields,
142
- resource: proc { Spree.api.custom_field_serializer },
143
- if: proc { expand?('custom_fields') }
140
+ expandable_custom_fields
144
141
 
145
142
  typelize prior_price: ['PriceHistory', nullable: true],
146
143
  seller_id: [:string, nullable: true]
@@ -44,6 +44,8 @@ module Spree
44
44
  many :return_line_items,
45
45
  resource: proc { Spree.api.return_line_item_serializer },
46
46
  if: proc { expand?('return_line_items') }
47
+
48
+ expandable_custom_fields
47
49
  end
48
50
  end
49
51
  end
@@ -5,12 +5,33 @@ module Spree
5
5
  class InvitationSerializer < V3::BaseSerializer
6
6
  typelize email: :string, status: [:string, enum: Spree::Invitation.statuses, enum_type_name: 'InvitationStatus'],
7
7
  expires_at: [:string, nullable: true],
8
- accepted_at: [:string, nullable: true]
8
+ accepted_at: [:string, nullable: true],
9
+ inviter_email: :string,
10
+ invitee_exists: [:boolean, optional: true],
11
+ seller: '{ id: string; name: string }'
9
12
 
10
13
  attributes :email,
11
14
  created_at: :iso8601, expires_at: :iso8601, accepted_at: :iso8601
12
15
 
13
16
  attributes status: :string
17
+
18
+ attribute :inviter_email do |invitation|
19
+ invitation.inviter.email
20
+ end
21
+
22
+ # Drives the acceptance page's sign-in vs sign-up branch, so only the
23
+ # public lookup carries it: whoever holds the emailed link already
24
+ # knows the address. A seller's team screen does not get to learn
25
+ # which addresses hold accounts elsewhere on the marketplace.
26
+ attribute :invitee_exists, if: proc { params[:acceptance] } do |invitation|
27
+ invitation.invitee_account.present?
28
+ end
29
+
30
+ # The smallest shape the acceptance page's title ("Join <seller>")
31
+ # needs; the page is public, so nothing more of the seller goes out.
32
+ attribute :seller do |invitation|
33
+ { id: invitation.resource.prefixed_id, name: invitation.resource.name }
34
+ end
14
35
  end
15
36
  end
16
37
  end
@@ -17,7 +17,7 @@ module Spree
17
17
  products_count: :number,
18
18
  default_currency: [:string, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
19
19
  supported_currencies: [:string, multi: true, enum: Spree::Money::Rounding::CURRENCY_CODES, enum_type_name: 'CurrencyCode'],
20
- timezone: [:string, nullable: true]
20
+ timezone: [:string, nullable: true, enum: Spree::TimeZones::SUGGESTED, enum_type_name: 'TimeZone']
21
21
 
22
22
  attributes :timezone,
23
23
  :status, :legal_name, :registration_number,
@@ -42,6 +42,8 @@ module Spree
42
42
  many :policies,
43
43
  resource: proc { Spree.api.policy_serializer },
44
44
  if: proc { expand?('policies') }
45
+
46
+ expandable_custom_fields
45
47
  end
46
48
  end
47
49
  end
@@ -7,6 +7,8 @@ module Spree
7
7
  money_attributes :amount, :amount_used, :amount_remaining, :display_amount,
8
8
  :display_amount_used, :display_amount_remaining
9
9
  attributes :currency
10
+
11
+ expandable_custom_fields
10
12
  end
11
13
  end
12
14
  end
@@ -0,0 +1,16 @@
1
+ module Spree
2
+ module Api
3
+ module V3
4
+ # The current store's public identity and default SEO metadata, in the
5
+ # request's locale. Missing translations fall back to the store's default
6
+ # locale.
7
+ class StoreSerializer < BaseSerializer
8
+ typelize name: :string,
9
+ seo_title: [:string, nullable: true],
10
+ meta_description: [:string, nullable: true]
11
+
12
+ attributes :name, :seo_title, :meta_description
13
+ end
14
+ end
15
+ end
16
+ end
@@ -127,10 +127,7 @@ module Spree
127
127
 
128
128
  many :option_values, resource: proc { Spree.api.option_value_serializer }
129
129
 
130
- many :storefront_custom_fields,
131
- key: :custom_fields,
132
- resource: proc { Spree.api.custom_field_serializer },
133
- if: proc { expand?('custom_fields') }
130
+ expandable_custom_fields
134
131
 
135
132
  typelize prior_price: ['PriceHistory', nullable: true]
136
133