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.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/app/controllers/concerns/spree/api/v3/admin/embed_permissions.rb +6 -1
- data/app/controllers/spree/api/v3/admin/admin_users_controller.rb +10 -0
- data/app/controllers/spree/api/v3/admin/invitation_acceptances_controller.rb +8 -4
- data/app/controllers/spree/api/v3/admin/sellers_controller.rb +1 -1
- data/app/controllers/spree/api/v3/admin/store_controller.rb +23 -7
- data/app/controllers/spree/api/v3/seller/invitation_acceptances_controller.rb +15 -5
- data/app/controllers/spree/api/v3/store/customers_controller.rb +1 -0
- data/app/controllers/spree/api/v3/store/store_controller.rb +25 -0
- data/app/serializers/spree/api/v3/address_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/address_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/admin_user_serializer.rb +20 -2
- data/app/serializers/spree/api/v3/admin/category_serializer.rb +1 -3
- data/app/serializers/spree/api/v3/admin/claim_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/collection_serializer.rb +1 -4
- data/app/serializers/spree/api/v3/admin/company_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/credit_card_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/customer_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/delivery_method_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/fulfillment_serializer.rb +1 -0
- data/app/serializers/spree/api/v3/admin/gift_card_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/invitation_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/admin/line_item_serializer.rb +1 -0
- data/app/serializers/spree/api/v3/admin/media_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/newsletter_subscriber_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/option_type_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/option_value_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/order_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/payment_method_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/payment_serializer.rb +8 -2
- data/app/serializers/spree/api/v3/admin/payment_source_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/product_serializer.rb +1 -3
- data/app/serializers/spree/api/v3/admin/return_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/seller_payout_serializer.rb +2 -1
- data/app/serializers/spree/api/v3/admin/seller_serializer.rb +4 -0
- data/app/serializers/spree/api/v3/admin/session_serializer.rb +17 -0
- data/app/serializers/spree/api/v3/admin/store_credit_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/admin/store_serializer.rb +3 -4
- data/app/serializers/spree/api/v3/admin/variant_serializer.rb +1 -3
- data/app/serializers/spree/api/v3/base_serializer.rb +28 -0
- data/app/serializers/spree/api/v3/category_serializer.rb +1 -4
- data/app/serializers/spree/api/v3/claim_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/collection_serializer.rb +1 -4
- data/app/serializers/spree/api/v3/company_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/credit_card_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/customer_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/delivery_method_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/fulfillment_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/gift_card_serializer.rb +1 -0
- data/app/serializers/spree/api/v3/line_item_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/media_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/newsletter_subscriber_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/option_type_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/option_value_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/order_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/payment_method_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/payment_serializer.rb +3 -1
- data/app/serializers/spree/api/v3/payment_source_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/product_serializer.rb +1 -4
- data/app/serializers/spree/api/v3/return_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/seller/invitation_serializer.rb +22 -1
- data/app/serializers/spree/api/v3/seller/profile_serializer.rb +1 -1
- data/app/serializers/spree/api/v3/seller_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/store_credit_serializer.rb +2 -0
- data/app/serializers/spree/api/v3/store_serializer.rb +16 -0
- data/app/serializers/spree/api/v3/variant_serializer.rb +1 -4
- data/app/services/spree/api/v3/request_schema.rb +15 -7
- data/config/routes.rb +5 -2
- data/lib/spree/api/agent_workflow_endpoints.rb +2 -2
- data/lib/spree/api/agent_write_schemas.rb +6 -6
- data/lib/spree/api/dependencies.rb +2 -2
- data/lib/spree/api/enum_types.rb +2 -1
- data/lib/spree/api/oauth.rb +40 -20
- data/lib/typelizer/open_enums.rb +22 -3
- data/openapi/admin.yaml +87631 -0
- data/openapi/store.yaml +25412 -0
- metadata +12 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3bc1eebac54270cff24aa58f2319414c1d2c3d3e2b62bc73ed1a99b3dcc8cef3
|
|
4
|
+
data.tar.gz: 63c9e47df2e22549f57a66be0af2bf781d35d44cfb42f70a7edacdc932f60dd2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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://
|
|
137
|
-
- [
|
|
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: '
|
|
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 =
|
|
78
|
-
return
|
|
77
|
+
existing = invitation.invitee_account
|
|
78
|
+
return create_new_invitee(invitation) unless existing
|
|
79
79
|
|
|
80
|
-
|
|
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 :
|
|
11
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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 =
|
|
101
|
-
return
|
|
100
|
+
existing = invitation.invitee_account
|
|
101
|
+
return create_new_invitee(invitation) unless existing
|
|
102
102
|
|
|
103
|
-
|
|
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
|
|
@@ -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
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -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
|
-
|
|
40
|
+
invitation.invitee_account.present?
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
# Minimal store identity for the unauthenticated acceptance page's
|
|
@@ -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
|
|
@@ -108,9 +108,7 @@ module Spree
|
|
|
108
108
|
resource: proc { Spree.api.admin_collection_serializer },
|
|
109
109
|
if: proc { expand?('collections') }
|
|
110
110
|
|
|
111
|
-
|
|
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 },
|
|
@@ -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
|
|
@@ -2,10 +2,10 @@ module Spree
|
|
|
2
2
|
module Api
|
|
3
3
|
module V3
|
|
4
4
|
module Admin
|
|
5
|
-
class StoreSerializer < V3::
|
|
6
|
-
typelize
|
|
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
|
-
|
|
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 },
|