spree_api 6.0.0 → 6.0.2

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -2
  3. data/app/controllers/concerns/spree/api/v3/admin/embed_permissions.rb +6 -1
  4. data/app/controllers/spree/api/v3/admin/admin_users_controller.rb +10 -0
  5. data/app/controllers/spree/api/v3/admin/invitation_acceptances_controller.rb +8 -4
  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/seller/invitation_acceptances_controller.rb +15 -5
  9. data/app/controllers/spree/api/v3/store/customers_controller.rb +1 -0
  10. data/app/controllers/spree/api/v3/store/store_controller.rb +25 -0
  11. data/app/serializers/spree/api/v3/address_serializer.rb +2 -0
  12. data/app/serializers/spree/api/v3/admin/address_serializer.rb +2 -0
  13. data/app/serializers/spree/api/v3/admin/admin_user_serializer.rb +20 -2
  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/media_serializer.rb +2 -0
  26. data/app/serializers/spree/api/v3/admin/newsletter_subscriber_serializer.rb +2 -0
  27. data/app/serializers/spree/api/v3/admin/option_type_serializer.rb +2 -0
  28. data/app/serializers/spree/api/v3/admin/option_value_serializer.rb +2 -0
  29. data/app/serializers/spree/api/v3/admin/order_serializer.rb +2 -0
  30. data/app/serializers/spree/api/v3/admin/payment_method_serializer.rb +2 -0
  31. data/app/serializers/spree/api/v3/admin/payment_serializer.rb +8 -2
  32. data/app/serializers/spree/api/v3/admin/payment_source_serializer.rb +2 -0
  33. data/app/serializers/spree/api/v3/admin/product_serializer.rb +1 -3
  34. data/app/serializers/spree/api/v3/admin/return_serializer.rb +2 -0
  35. data/app/serializers/spree/api/v3/admin/seller_payout_serializer.rb +2 -1
  36. data/app/serializers/spree/api/v3/admin/seller_serializer.rb +4 -0
  37. data/app/serializers/spree/api/v3/admin/session_serializer.rb +17 -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 +5 -2
  70. data/lib/spree/api/agent_workflow_endpoints.rb +2 -2
  71. data/lib/spree/api/agent_write_schemas.rb +6 -6
  72. data/lib/spree/api/dependencies.rb +2 -2
  73. data/lib/spree/api/enum_types.rb +2 -1
  74. data/lib/spree/api/oauth.rb +40 -20
  75. data/lib/typelizer/open_enums.rb +22 -3
  76. data/openapi/admin.yaml +87631 -0
  77. data/openapi/store.yaml +25412 -0
  78. metadata +12 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02e3a969bdbac77ab7eba1edb5986472deb10d660fbad8b2c51df6e586f97709
4
- data.tar.gz: c3f880037bc5751de97fbccdbcacae67d643c8ddf8aefa66a3ac804d488645a7
3
+ metadata.gz: 3bc1eebac54270cff24aa58f2319414c1d2c3d3e2b62bc73ed1a99b3dcc8cef3
4
+ data.tar.gz: 63c9e47df2e22549f57a66be0af2bf781d35d44cfb42f70a7edacdc932f60dd2
5
5
  SHA512:
6
- metadata.gz: cb6694163e15d45f56831fc65547a3a5728f022dd2d1e0610ea758b844ef05b1a5fd80340fad8cb4b75ef2f525582cd423212a052da3406e2e241822137c64ed
7
- data.tar.gz: 423fe47f6ce5d99bd55eea7613e2594bc3d4c382eee23dd47ff28e1b2b1f43f678c8034c96e12ef6dafd30fa537d946a3f13d0e9c899bdf0f005c93c62c89df5
6
+ metadata.gz: 4dc86cc7163081943b538408538ff9499ca25848f6bd3656933a8b79cc172d5a629e7cea4b0b22f5c55e22ba7a7b2fa342f8c360155b0759b879876f21d67972
7
+ data.tar.gz: ec1f8e51808bf0175f6c1ee135bc440cffcdff1e22eff9e920ac92e5d1610e22d8be00de38080d33acd629968b17c0f326b2c6a1651b3c7ee5643b7c5df52183
data/README.md CHANGED
@@ -133,5 +133,6 @@ bundle exec rspec
133
133
 
134
134
  ## Documentation
135
135
 
136
- - [API Reference](https://docs.spreecommerce.org/api)
137
- - [Authentication Guide](https://docs.spreecommerce.org/developer/api/authentication)
136
+ - [API Reference](https://spreecommerce.org/docs/api-reference)
137
+ - [Store API authentication](https://spreecommerce.org/docs/api-reference/store-api/authentication)
138
+ - [Admin API authentication](https://spreecommerce.org/docs/api-reference/admin-api/authentication)
@@ -29,7 +29,12 @@ module Spree
29
29
  'gift_card' => 'read_gift_cards',
30
30
  'gift_cards' => 'read_gift_cards',
31
31
  'store_credit' => 'read_store_credits',
32
- 'store_credits' => 'read_store_credits'
32
+ 'store_credits' => 'read_store_credits',
33
+ # The admin user serializer is nested in gift cards, task runs and
34
+ # tokens; its sessions carry IP addresses and its inviter is
35
+ # another staff member.
36
+ 'sessions' => 'read_staff',
37
+ 'inviter' => 'read_staff'
33
38
  }.freeze
34
39
 
35
40
  protected
@@ -72,6 +72,16 @@ module Spree
72
72
  [{ spree_roles: :resource, avatar_attachment: :blob }]
73
73
  end
74
74
 
75
+ # Sessions carry IP addresses and the inviter costs a query per row,
76
+ # so both are shown one person at a time.
77
+ ONE_AT_A_TIME_EXPANDS = %w[sessions inviter].freeze
78
+
79
+ def expand_list
80
+ return super unless action_name == 'index'
81
+
82
+ super.reject { |path| ONE_AT_A_TIME_EXPANDS.include?(path.split('.').first) }
83
+ end
84
+
75
85
  # Restrict to users with a role assignment on the current store.
76
86
  # `accessible_by` enforces CanCanCan on top. Deduplication happens via
77
87
  # an ID subquery rather than `SELECT DISTINCT *` — the users table is
@@ -12,7 +12,7 @@ module Spree
12
12
 
13
13
  request_params 'InvitationAcceptParams', action: :accept do |body|
14
14
  body.attribute :password, :string,
15
- description: 'Required when the invitee has no account yet: it creates one. An existing account signs in without it.'
15
+ description: 'Creates the account when the invitee has none yet. An existing account confirms it is theirs with it, unless the request is already signed in as that account.'
16
16
  body.attribute :password_confirmation, :string
17
17
  body.attribute :first_name, :string
18
18
  body.attribute :last_name, :string
@@ -74,10 +74,14 @@ module Spree
74
74
  # implicit: we look the user up by `invitation.email`, never by a
75
75
  # client-supplied email. The token is the credential.
76
76
  def resolve_or_create_invitee(invitation)
77
- existing = Spree.admin_user_class.find_by(email: invitation.email)
78
- return authenticate_existing(existing) if existing
77
+ existing = invitation.invitee_account
78
+ return create_new_invitee(invitation) unless existing
79
79
 
80
- create_new_invitee(invitation)
80
+ # Someone already signed in as the invitee has proven who they are.
81
+ authenticate_user
82
+ return existing if current_user == existing
83
+
84
+ authenticate_existing(existing)
81
85
  end
82
86
 
83
87
  def authenticate_existing(user)
@@ -195,7 +195,7 @@ module Spree
195
195
  # every seller on the page, so it loads once. Applied to the scope
196
196
  # rather than the collection so a single-seller read gets it too.
197
197
  def scope_includes
198
- [:billing_address, :requirement_submissions, { stock_locations: [] },
198
+ [:billing_address, :requirement_submissions, :external_references, { stock_locations: [] },
199
199
  { store: :seller_requirements, logo_attachment: :blob, cover_photo_attachment: :blob }]
200
200
  end
201
201
 
@@ -7,8 +7,15 @@ module Spree
7
7
 
8
8
  request_params :store do |body|
9
9
  body.attribute :name, :string, example: 'My Store'
10
- body.attribute :admin_locale, :string, example: 'en'
11
- body.attribute :timezone, :string, example: 'Europe/Berlin'
10
+ body.attribute :seo_title, :string,
11
+ nullable: true,
12
+ description: "The storefront's default page title, in the store's default language. Translate it through the translations endpoints."
13
+ body.attribute :meta_description, :string,
14
+ nullable: true,
15
+ description: "The storefront's default meta description, in the store's default language."
16
+ body.attribute :admin_locale, :locale, nullable: true, example: 'en',
17
+ description: 'The language the dashboard opens in for every staff member; null lets each use their own.'
18
+ body.attribute :timezone, :time_zone, example: 'Europe/Berlin'
12
19
  body.attribute :weight_unit, :weight_unit
13
20
  body.attribute :unit_system, :string, choices: Spree::Store::UNIT_SYSTEMS
14
21
  body.attribute :storefront_access, :string,
@@ -143,17 +150,19 @@ module Spree
143
150
  # GET /api/v3/admin/store
144
151
  def show
145
152
  authorize! :show, current_store
146
- render json: serialize_store
153
+ render json: in_default_locale { serialize_store }
147
154
  end
148
155
 
149
156
  # PATCH /api/v3/admin/store
150
157
  def update
151
158
  authorize! :update, current_store
152
159
 
153
- if current_store.update(permitted_params)
154
- render json: serialize_store
155
- else
156
- render_validation_error(current_store.errors)
160
+ in_default_locale do
161
+ if current_store.update(permitted_params)
162
+ render json: serialize_store
163
+ else
164
+ render_validation_error(current_store.errors)
165
+ end
157
166
  end
158
167
  end
159
168
 
@@ -177,6 +186,13 @@ module Spree
177
186
 
178
187
  private
179
188
 
189
+ # Settings hold the store's default-language values, whatever locale
190
+ # the request resolved to. Other languages are written through the
191
+ # translations endpoints.
192
+ def in_default_locale(&)
193
+ Mobility.with_locale(current_store.default_locale, &)
194
+ end
195
+
180
196
  def describe(provider_classes)
181
197
  provider_classes.map do |provider_class|
182
198
  {
@@ -24,7 +24,7 @@ module Spree
24
24
 
25
25
  request_params 'InvitationAcceptParams', action: :accept do |body|
26
26
  body.attribute :password, :string,
27
- description: 'Sets the password of a new account, or confirms the password of an existing one.'
27
+ description: 'Sets the password of a new account, or confirms the password of an existing one, unless the request is already signed in as that account.'
28
28
  body.attribute :password_confirmation, :string
29
29
  body.attribute :first_name, :string, description: 'Used only when the invitation creates a new account.'
30
30
  body.attribute :last_name, :string, description: 'Used only when the invitation creates a new account.'
@@ -35,7 +35,7 @@ module Spree
35
35
  return unless load_invitation
36
36
 
37
37
  render json: Spree.api.seller_invitation_serializer.new(
38
- @invitation, params: { store: @invitation.store }
38
+ @invitation, params: { store: @invitation.store, acceptance: true }
39
39
  ).serializable_hash
40
40
  end
41
41
 
@@ -97,10 +97,14 @@ module Spree
97
97
  # implicit: we look the user up by `invitation.email`, never by a
98
98
  # client-supplied email. The token is the credential.
99
99
  def resolve_or_create_invitee(invitation)
100
- existing = Spree.admin_user_class.find_by(email: invitation.email)
101
- return authenticate_existing(existing) if existing
100
+ existing = invitation.invitee_account
101
+ return create_new_invitee(invitation) unless existing
102
102
 
103
- create_new_invitee(invitation)
103
+ # Someone already signed in as the invitee has proven who they are.
104
+ authenticate_user
105
+ return existing if current_user == existing
106
+
107
+ authenticate_existing(existing)
104
108
  end
105
109
 
106
110
  def authenticate_existing(user)
@@ -151,6 +155,12 @@ module Spree
151
155
  user.sellers.map { |seller| { id: seller.prefixed_id, name: seller.name, status: seller.status } }
152
156
  end
153
157
 
158
+ # The plain v3 base expects a storefront token; the session this
159
+ # page may carry is a seller panel one.
160
+ def expected_audience
161
+ Spree::Api::V3::JwtAuthentication::JWT_AUDIENCE_SELLER
162
+ end
163
+
154
164
  def request_env_for_token
155
165
  { ip_address: request.remote_ip, user_agent: request.user_agent&.truncate(255) }
156
166
  end
@@ -111,6 +111,7 @@ module Spree
111
111
  currency: current_currency,
112
112
  user: current_user,
113
113
  includes: [],
114
+ expand: expand_list,
114
115
  hide_prices: hide_prices?
115
116
  }
116
117
  end
@@ -0,0 +1,25 @@
1
+ module Spree
2
+ module Api
3
+ module V3
4
+ module Store
5
+ # Exposes the store the request resolved to, so a storefront can render
6
+ # its name and default SEO metadata in the requested locale.
7
+ class StoreController < Store::BaseController
8
+ # A gated storefront still needs a page title on its sign-in wall.
9
+ allow_guest_storefront_access!
10
+
11
+ # GET /api/v3/store/store
12
+ def show
13
+ render json: serialize_resource(current_store)
14
+ end
15
+
16
+ protected
17
+
18
+ def serializer_class
19
+ Spree.api.store_serializer
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -35,6 +35,8 @@ module Spree
35
35
  # The address book the entry belongs to. Null for an address in no
36
36
  # book: one a guest typed in, or the copy a placed order keeps.
37
37
  one :owner, resource: proc { Spree.api.address_owner_serializer }
38
+
39
+ expandable_custom_fields
38
40
  end
39
41
  end
40
42
  end
@@ -28,6 +28,8 @@ module Spree
28
28
  prefixed_id_attributes customer_id: :customer_owner
29
29
 
30
30
  one :owner, resource: proc { Spree.api.admin_address_owner_serializer }
31
+
32
+ expandable_custom_fields admin: true
31
33
  end
32
34
  end
33
35
  end
@@ -10,11 +10,29 @@ module Spree
10
10
  selected_locale: [:string, nullable: true],
11
11
  avatar_url: [:string, nullable: true],
12
12
  roles: 'Array<{ id: string; name: string }>',
13
- stores: 'Array<{ id: string; name: string; code: string }>'
13
+ stores: 'Array<{ id: string; name: string; code: string }>',
14
+ status: [:string, enum: Spree::AdminUserMethods::STATUSES, enum_type_name: 'AdminUserStatus'],
15
+ last_active_at: [:string, nullable: true],
16
+ inviter: ['Actor', nullable: true]
14
17
 
15
- attributes :email, :first_name, :last_name, :full_name, :selected_locale,
18
+ attributes :email, :first_name, :last_name, :full_name, :selected_locale, :status,
16
19
  created_at: :iso8601, updated_at: :iso8601
17
20
 
21
+ attribute :last_active_at do |user|
22
+ user.try(:last_active_at)&.iso8601
23
+ end
24
+
25
+ # Carries IP addresses, so sent only to the caller who asks for it.
26
+ many :sessions,
27
+ resource: proc { Spree.api.admin_session_serializer },
28
+ source: ->(_params) { active_sessions },
29
+ if: proc { expand?('sessions') }
30
+
31
+ one :inviter,
32
+ resource: proc { Spree.api.admin_actor_serializer },
33
+ source: ->(params) { invited_by(params&.dig(:store)) },
34
+ if: proc { expand?('inviter') }
35
+
18
36
  attribute :avatar_url do |user|
19
37
  image_url_for(user.avatar)
20
38
  end
@@ -28,9 +28,7 @@ module Spree
28
28
  resource: proc { Spree.api.admin_category_serializer },
29
29
  if: proc { expand?('ancestors') }
30
30
 
31
- many :custom_fields,
32
- resource: proc { Spree.api.admin_custom_field_serializer },
33
- if: proc { expand?('custom_fields') }
31
+ expandable_custom_fields admin: true
34
32
  end
35
33
  end
36
34
  end
@@ -26,6 +26,8 @@ module Spree
26
26
  one :reason, resource: proc { Spree.api.admin_claim_reason_serializer }, if: proc { expand?('reason') }
27
27
  one :order, resource: proc { Spree.api.admin_order_serializer }, if: proc { expand?('order') }
28
28
  many :refunds, resource: proc { Spree.api.admin_refund_serializer }, if: proc { expand?('refunds') }
29
+
30
+ expandable_custom_fields admin: true
29
31
  end
30
32
  end
31
33
  end
@@ -18,10 +18,7 @@ module Spree
18
18
  resource: proc { Spree.api.admin_collection_rule_serializer },
19
19
  if: proc { expand?('rules') }
20
20
 
21
- # Override inherited custom_fields to use the admin serializer.
22
- many :custom_fields,
23
- resource: proc { Spree.api.admin_custom_field_serializer },
24
- if: proc { expand?('custom_fields') }
21
+ expandable_custom_fields admin: true
25
22
  end
26
23
  end
27
24
  end
@@ -30,6 +30,8 @@ module Spree
30
30
  many :memberships,
31
31
  resource: proc { Spree.api.admin_company_membership_serializer },
32
32
  if: proc { expand?('memberships') }
33
+
34
+ expandable_custom_fields admin: true
33
35
  end
34
36
  end
35
37
  end
@@ -11,6 +11,8 @@ module Spree
11
11
 
12
12
  attributes :metadata,
13
13
  created_at: :iso8601, updated_at: :iso8601
14
+
15
+ expandable_custom_fields admin: true
14
16
  end
15
17
  end
16
18
  end
@@ -99,6 +99,8 @@ module Spree
99
99
  many :companies,
100
100
  resource: proc { Spree.api.admin_company_serializer },
101
101
  if: proc { expand?('companies') }
102
+
103
+ expandable_custom_fields admin: true
102
104
  end
103
105
  end
104
106
  end
@@ -59,6 +59,8 @@ module Spree
59
59
  calculator = record.calculator
60
60
  { type: calculator.class.api_type, preferences: calculator.serialized_preferences } if calculator
61
61
  end
62
+
63
+ expandable_custom_fields admin: true
62
64
  end
63
65
  end
64
66
  end
@@ -61,6 +61,7 @@ module Spree
61
61
  resource: proc { Spree.api.admin_order_serializer },
62
62
  if: proc { expand?('order') }
63
63
 
64
+ expandable_custom_fields admin: true
64
65
  end
65
66
  end
66
67
  end
@@ -51,6 +51,8 @@ module Spree
51
51
  many :orders,
52
52
  resource: proc { Spree.api.admin_order_serializer },
53
53
  if: proc { expand?('orders') }
54
+
55
+ expandable_custom_fields admin: true
54
56
  end
55
57
  end
56
58
  end
@@ -37,7 +37,7 @@ module Spree
37
37
  # Looked up by email so an admin who's already on another store sees
38
38
  # the password prompt, not a fresh account form.
39
39
  attribute :invitee_exists do |invitation|
40
- Spree.admin_user_class.exists?(email: invitation.email)
40
+ invitation.invitee_account.present?
41
41
  end
42
42
 
43
43
  # Minimal store identity for the unauthenticated acceptance page's
@@ -85,6 +85,7 @@ module Spree
85
85
  resource: proc { Spree.api.admin_tax_category_serializer },
86
86
  if: proc { expand?('tax_category') }
87
87
 
88
+ expandable_custom_fields admin: true
88
89
  end
89
90
  end
90
91
  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
@@ -16,7 +16,9 @@ module Spree
16
16
  cvv_response_message: [:string, nullable: true],
17
17
  gateway_dashboard_payment_url: [:string, nullable: true],
18
18
  avs_risky: [:boolean, comment: 'Whether the card issuer reported that the billing address did not match.'],
19
- cvv_risky: [:boolean, comment: 'Whether the card issuer reported that the security code did not match.']
19
+ cvv_risky: [:boolean, comment: 'Whether the card issuer reported that the security code did not match.'],
20
+ can_void: [:boolean, comment: 'Whether the payment can be voided now, as decided by its payment method.'],
21
+ can_capture: [:boolean, comment: 'Whether the payment can be captured now, as decided by its payment method.']
20
22
 
21
23
  attributes :metadata, :avs_response, :cvv_response_code, :cvv_response_message,
22
24
  :gateway_dashboard_payment_url,
@@ -24,6 +26,8 @@ module Spree
24
26
 
25
27
  attribute(:avs_risky, &:is_avs_risky?)
26
28
  attribute(:cvv_risky, &:is_cvv_risky?)
29
+ attribute(:can_void, &:can_void?)
30
+ attribute(:can_capture, &:can_capture?)
27
31
 
28
32
  money_attributes :captured_amount
29
33
  typelize captured_amount: [:string, nullable: false]
@@ -45,7 +49,7 @@ module Spree
45
49
  Spree.api.admin_payment_source_serializer
46
50
  end
47
51
 
48
- serializer.new(payment.source).to_h
52
+ serializer.new(payment.source, params: nested_params('source')).to_h
49
53
  end
50
54
 
51
55
  many :capture_events,
@@ -65,6 +69,8 @@ module Spree
65
69
  many :payment_splits,
66
70
  resource: proc { Spree.api.admin_payment_split_serializer },
67
71
  if: proc { expand?('payment_splits') }
72
+
73
+ expandable_custom_fields admin: true
68
74
  end
69
75
  end
70
76
  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
@@ -0,0 +1,17 @@
1
+ module Spree
2
+ module Api
3
+ module V3
4
+ module Admin
5
+ # A signed-in session of a staff account ({Spree::RefreshToken}),
6
+ # without its token.
7
+ class SessionSerializer < V3::BaseSerializer
8
+ typelize ip_address: [:string, nullable: true],
9
+ user_agent: [:string, nullable: true],
10
+ last_active_at: :string
11
+
12
+ attributes :ip_address, :user_agent, last_active_at: :iso8601
13
+ end
14
+ end
15
+ end
16
+ end
17
+ 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 },