spree_api 4.1.8 → 4.2.0.rc1
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/app/controllers/concerns/spree/api/v2/storefront/order_concern.rb +4 -0
- data/app/controllers/spree/api/base_controller.rb +1 -3
- data/app/controllers/spree/api/errors_controller.rb +1 -1
- data/app/controllers/spree/api/v1/taxons_controller.rb +6 -1
- data/app/controllers/spree/api/v1/users_controller.rb +35 -9
- data/app/controllers/spree/api/v2/base_controller.rb +6 -1
- data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +77 -0
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +1 -2
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +27 -0
- data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +1 -1
- data/app/helpers/spree/api/api_helpers.rb +4 -3
- data/app/models/spree/api_dependencies.rb +10 -1
- data/app/serializers/spree/v2/storefront/address_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +2 -1
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +2 -1
- data/app/serializers/spree/v2/storefront/product_serializer.rb +2 -2
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +3 -1
- data/app/serializers/spree/v2/storefront/stock_location_serializer.rb +11 -0
- data/app/serializers/spree/v2/storefront/store_serializer.rb +13 -0
- data/app/serializers/spree/v2/storefront/variant_serializer.rb +2 -2
- data/app/views/spree/api/v1/products/show.rabl +4 -0
- data/config/routes.rb +2 -0
- data/docs/v2/storefront/index.yaml +206 -12
- data/lib/spree/api/controller_setup.rb +0 -1
- data/lib/spree/api/testing_support/v2/base.rb +1 -1
- data/lib/spree/api/testing_support/v2/current_order.rb +4 -0
- data/spree_api.gemspec +1 -1
- metadata +14 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ca201da4875f262850ded05d71868a5161f3e8055c6047b544bef63f536e5d3
|
4
|
+
data.tar.gz: cfc2c37c3bdd2041b91cfa4cffad2643f4131a69fb8793b6eb6c793e5ae17ee6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfd25ddcca9e0fb04dd7141cfa5fb153ff43de9f0137fa3d78618300a71372c5057de303ab0728da69aa08c3e0a0eba0675493bf0bf42caa8f325207fb94603c
|
7
|
+
data.tar.gz: 4798f5ddbfc85d778adcfd0509ea7d2361f1464a61ae6a194d4d8f7d1014738e570a89c17b95c735317f25394ca8ad75c148e1fc81d4a2f195a986a8ac63f55a
|
@@ -34,6 +34,10 @@ module Spree
|
|
34
34
|
)
|
35
35
|
end
|
36
36
|
|
37
|
+
def supported_currencies
|
38
|
+
current_store.supported_currencies_list
|
39
|
+
end
|
40
|
+
|
37
41
|
def serialize_order(order)
|
38
42
|
resource_serializer.new(order.reload, include: resource_includes, fields: sparse_fields).serializable_hash
|
39
43
|
end
|
@@ -2,9 +2,7 @@ require_dependency 'spree/api/controller_setup'
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module Api
|
5
|
-
class BaseController < ActionController::
|
6
|
-
protect_from_forgery unless: -> { request.format.json? || request.format.xml? }
|
7
|
-
|
5
|
+
class BaseController < ActionController::API
|
8
6
|
include Spree::Api::ControllerSetup
|
9
7
|
include Spree::Core::ControllerHelpers::Store
|
10
8
|
include Spree::Core::ControllerHelpers::StrongParameters
|
@@ -74,7 +74,12 @@ module Spree
|
|
74
74
|
|
75
75
|
def taxonomy
|
76
76
|
if params[:taxonomy_id].present?
|
77
|
-
@taxonomy ||=
|
77
|
+
@taxonomy ||=
|
78
|
+
if defined?(SpreeGlobalize)
|
79
|
+
Spree::Taxonomy.includes(:translations, taxons: [:translations]).accessible_by(current_ability, :show).find(params[:taxonomy_id])
|
80
|
+
else
|
81
|
+
Spree::Taxonomy.accessible_by(current_ability, :show).find(params[:taxonomy_id])
|
82
|
+
end
|
78
83
|
end
|
79
84
|
end
|
80
85
|
|
@@ -5,22 +5,48 @@ module Spree
|
|
5
5
|
rescue_from Spree::Core::DestroyWithOrdersError, with: :error_during_processing
|
6
6
|
|
7
7
|
def index
|
8
|
-
|
8
|
+
users
|
9
9
|
|
10
10
|
if params[:ids]
|
11
|
-
|
12
|
-
elsif params
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
users_with_addresses_ids = (users_with_ship_address.ids + users_with_bill_address.ids).compact.uniq
|
17
|
-
@users = @users.with_email_or_addresses_ids(params[:q][:email_start], users_with_addresses_ids)
|
11
|
+
load_users_by_ids
|
12
|
+
elsif params.dig(:q, :ship_address_firstname_start)
|
13
|
+
load_users_by_address
|
14
|
+
elsif params.dig(:q, :email_start)
|
15
|
+
load_users_by_email
|
18
16
|
end
|
19
17
|
|
18
|
+
prepare_index_response
|
19
|
+
respond_with(@users)
|
20
|
+
end
|
21
|
+
|
22
|
+
def users
|
23
|
+
@users ||= Spree.user_class.accessible_by(current_ability, :show)
|
24
|
+
end
|
25
|
+
|
26
|
+
def load_users_by_ids
|
27
|
+
@users = @users.where(id: params[:ids])
|
28
|
+
end
|
29
|
+
|
30
|
+
def load_users_by_address
|
31
|
+
address_params = params[:q][:ship_address_firstname_start] ||
|
32
|
+
params[:q][:ship_address_lastname_start] ||
|
33
|
+
params[:q][:bill_address_firstname_start] ||
|
34
|
+
params[:q][:bill_address_lastname_start]
|
35
|
+
@users = @users.with_email_or_address(params[:q][:email_start], address_params)
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_users_by_email
|
39
|
+
@users = @users.with_email(params[:q][:email_start])
|
40
|
+
end
|
41
|
+
|
42
|
+
def paginate_users
|
20
43
|
@users = @users.page(params[:page]).per(params[:per_page])
|
44
|
+
end
|
45
|
+
|
46
|
+
def prepare_index_response
|
47
|
+
paginate_users
|
21
48
|
expires_in 15.minutes, public: true
|
22
49
|
headers['Surrogate-Control'] = "max-age=#{15.minutes}"
|
23
|
-
respond_with(@users)
|
24
50
|
end
|
25
51
|
|
26
52
|
def show
|
@@ -53,7 +53,12 @@ module Spree
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def spree_current_user
|
56
|
-
|
56
|
+
return nil unless doorkeeper_token
|
57
|
+
return @spree_current_user if @spree_current_user
|
58
|
+
|
59
|
+
doorkeeper_authorize!
|
60
|
+
|
61
|
+
@spree_current_user ||= Spree.user_class.find_by(id: doorkeeper_token.resource_owner_id)
|
57
62
|
end
|
58
63
|
|
59
64
|
def spree_authorize!(action, subject, *args)
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
module Account
|
6
|
+
class AddressesController < ::Spree::Api::V2::BaseController
|
7
|
+
before_action :require_spree_current_user
|
8
|
+
|
9
|
+
def index
|
10
|
+
render_serialized_payload { serialize_collection(collection) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
result = create_service.call(user: spree_current_user, address_params: address_params)
|
15
|
+
render_result(result)
|
16
|
+
end
|
17
|
+
|
18
|
+
def update
|
19
|
+
result = update_service.call(address: resource, address_params: address_params)
|
20
|
+
render_result(result)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def collection
|
26
|
+
collection_finder.new(scope: scope, params: params).execute
|
27
|
+
end
|
28
|
+
|
29
|
+
def resource
|
30
|
+
@resource ||= scope.find(params[:id])
|
31
|
+
end
|
32
|
+
|
33
|
+
def scope
|
34
|
+
spree_current_user.addresses
|
35
|
+
end
|
36
|
+
|
37
|
+
def collection_finder
|
38
|
+
Spree::Api::Dependencies.storefront_address_finder.constantize
|
39
|
+
end
|
40
|
+
|
41
|
+
def collection_serializer
|
42
|
+
Spree::Api::Dependencies.storefront_address_serializer.constantize
|
43
|
+
end
|
44
|
+
|
45
|
+
def resource_serializer
|
46
|
+
Spree::Api::Dependencies.storefront_address_serializer.constantize
|
47
|
+
end
|
48
|
+
|
49
|
+
def serialize_collection(collection)
|
50
|
+
collection_serializer.new(collection).serializable_hash
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_service
|
54
|
+
Spree::Api::Dependencies.storefront_account_create_address_service.constantize
|
55
|
+
end
|
56
|
+
|
57
|
+
def update_service
|
58
|
+
Spree::Api::Dependencies.storefront_account_update_address_service.constantize
|
59
|
+
end
|
60
|
+
|
61
|
+
def address_params
|
62
|
+
params.require(:address).permit(permitted_address_attributes)
|
63
|
+
end
|
64
|
+
|
65
|
+
def render_result(result)
|
66
|
+
if result.success?
|
67
|
+
render_serialized_payload { serialize_resource(result.value) }
|
68
|
+
else
|
69
|
+
render_error_payload(result.error)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -125,8 +125,7 @@ module Spree
|
|
125
125
|
def serialize_shipping_rates(shipments)
|
126
126
|
shipping_rates_serializer.new(
|
127
127
|
shipments,
|
128
|
-
include: [:shipping_rates]
|
129
|
-
params: { show_rates: true }
|
128
|
+
include: [:shipping_rates, :stock_location]
|
130
129
|
).serializable_hash
|
131
130
|
end
|
132
131
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
class StoresController < ::Spree::Api::V2::BaseController
|
6
|
+
def show
|
7
|
+
render_serialized_payload { serialize_resource(resource) }
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def scope
|
13
|
+
Spree::Store
|
14
|
+
end
|
15
|
+
|
16
|
+
def resource
|
17
|
+
scope.find_by!(code: params[:code])
|
18
|
+
end
|
19
|
+
|
20
|
+
def resource_serializer
|
21
|
+
Spree::Api::Dependencies.storefront_store_serializer.constantize
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -116,7 +116,7 @@ module Spree
|
|
116
116
|
@@address_attributes = [
|
117
117
|
:id, :firstname, :lastname, :full_name, :address1, :address2, :city,
|
118
118
|
:zipcode, :phone, :company, :alternative_phone, :country_id, :state_id,
|
119
|
-
:state_name, :state_text
|
119
|
+
:label, :state_name, :state_text
|
120
120
|
]
|
121
121
|
|
122
122
|
@@country_attributes = [:id, :iso_name, :iso, :iso3, :name, :numcode]
|
@@ -161,8 +161,9 @@ module Spree
|
|
161
161
|
|
162
162
|
@@store_attributes = [
|
163
163
|
:id, :name, :url, :meta_description, :meta_keywords, :seo_title,
|
164
|
-
:mail_from_address, :
|
165
|
-
:facebook, :twitter, :instagram
|
164
|
+
:mail_from_address, :customer_support_email, :default_currency,
|
165
|
+
:code, :default, :facebook, :twitter, :instagram,
|
166
|
+
:supported_currencies
|
166
167
|
]
|
167
168
|
|
168
169
|
@@tag_attributes = [:id, :name]
|
@@ -13,7 +13,9 @@ module Spree
|
|
13
13
|
:storefront_country_serializer, :storefront_current_order_finder, :storefront_completed_order_finder, :storefront_order_sorter,
|
14
14
|
:storefront_collection_paginator, :storefront_user_serializer, :storefront_products_sorter, :storefront_products_finder,
|
15
15
|
:storefront_product_serializer, :storefront_taxon_serializer, :storefront_taxon_finder, :storefront_find_by_variant_finder,
|
16
|
-
:storefront_cart_update_service, :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer
|
16
|
+
:storefront_cart_update_service, :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer,
|
17
|
+
:storefront_store_serializer, :storefront_address_serializer,
|
18
|
+
:storefront_account_create_address_service, :storefront_account_update_address_service, :storefront_address_finder
|
17
19
|
].freeze
|
18
20
|
|
19
21
|
attr_accessor *INJECTION_POINTS
|
@@ -48,7 +50,12 @@ module Spree
|
|
48
50
|
@storefront_checkout_remove_store_credit_service = Spree::Dependencies.checkout_remove_store_credit_service
|
49
51
|
@storefront_checkout_get_shipping_rates_service = Spree::Dependencies.checkout_get_shipping_rates_service
|
50
52
|
|
53
|
+
# account services
|
54
|
+
@storefront_account_create_address_service = Spree::Dependencies.account_create_address_service
|
55
|
+
@storefront_account_update_address_service = Spree::Dependencies.account_update_address_service
|
56
|
+
|
51
57
|
# serializers
|
58
|
+
@storefront_address_serializer = 'Spree::V2::Storefront::AddressSerializer'
|
52
59
|
@storefront_cart_serializer = 'Spree::V2::Storefront::CartSerializer'
|
53
60
|
@storefront_credit_card_serializer = 'Spree::V2::Storefront::CreditCardSerializer'
|
54
61
|
@storefront_country_serializer = 'Spree::V2::Storefront::CountrySerializer'
|
@@ -58,6 +65,7 @@ module Spree
|
|
58
65
|
@storefront_payment_method_serializer = 'Spree::V2::Storefront::PaymentMethodSerializer'
|
59
66
|
@storefront_product_serializer = 'Spree::V2::Storefront::ProductSerializer'
|
60
67
|
@storefront_estimated_shipment_serializer = 'Spree::V2::Storefront::EstimatedShippingRateSerializer'
|
68
|
+
@storefront_store_serializer = 'Spree::V2::Storefront::StoreSerializer'
|
61
69
|
|
62
70
|
# sorters
|
63
71
|
@storefront_order_sorter = Spree::Dependencies.order_sorter
|
@@ -67,6 +75,7 @@ module Spree
|
|
67
75
|
@storefront_collection_paginator = Spree::Dependencies.collection_paginator
|
68
76
|
|
69
77
|
# finders
|
78
|
+
@storefront_address_finder = Spree::Dependencies.address_finder
|
70
79
|
@storefront_country_finder = Spree::Dependencies.country_finder
|
71
80
|
@storefront_current_order_finder = Spree::Dependencies.current_order_finder
|
72
81
|
@storefront_completed_order_finder = Spree::Dependencies.completed_order_finder
|
@@ -5,7 +5,7 @@ module Spree
|
|
5
5
|
set_type :address
|
6
6
|
|
7
7
|
attributes :firstname, :lastname, :address1, :address2, :city, :zipcode, :phone, :state_name,
|
8
|
-
:company, :country_name, :country_iso3, :country_iso
|
8
|
+
:company, :country_name, :country_iso3, :country_iso, :label
|
9
9
|
|
10
10
|
attribute :state_code, &:state_abbr
|
11
11
|
attribute :state_name, &:state_name_text
|
@@ -8,7 +8,8 @@ module Spree
|
|
8
8
|
:updated_at, :completed_at, :included_tax_total, :additional_tax_total, :display_additional_tax_total,
|
9
9
|
:display_included_tax_total, :tax_total, :currency, :state, :token, :email,
|
10
10
|
:display_item_total, :display_ship_total, :display_adjustment_total, :display_tax_total,
|
11
|
-
:promo_total, :display_promo_total, :item_count, :special_instructions, :display_total
|
11
|
+
:promo_total, :display_promo_total, :item_count, :special_instructions, :display_total,
|
12
|
+
:pre_tax_item_amount, :display_pre_tax_item_amount, :pre_tax_total, :display_pre_tax_total
|
12
13
|
|
13
14
|
has_many :line_items
|
14
15
|
has_many :variants
|
@@ -9,7 +9,8 @@ module Spree
|
|
9
9
|
:display_adjustment_total, :additional_tax_total,
|
10
10
|
:discounted_amount, :display_discounted_amount,
|
11
11
|
:display_additional_tax_total, :promo_total, :display_promo_total,
|
12
|
-
:included_tax_total, :display_included_tax_total
|
12
|
+
:included_tax_total, :display_included_tax_total,
|
13
|
+
:pre_tax_amount, :display_pre_tax_amount
|
13
14
|
|
14
15
|
belongs_to :variant
|
15
16
|
end
|
@@ -5,8 +5,8 @@ module Spree
|
|
5
5
|
set_type :product
|
6
6
|
|
7
7
|
attributes :name, :description, :price, :currency, :display_price,
|
8
|
-
:
|
9
|
-
:updated_at
|
8
|
+
:compare_at_price, :display_compare_at_price, :available_on,
|
9
|
+
:slug, :meta_description, :meta_keywords, :updated_at
|
10
10
|
|
11
11
|
attribute :purchasable, &:purchasable?
|
12
12
|
attribute :in_stock, &:in_stock?
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Spree
|
2
|
+
module V2
|
3
|
+
module Storefront
|
4
|
+
class StoreSerializer < BaseSerializer
|
5
|
+
set_type :store
|
6
|
+
|
7
|
+
attributes :name, :url, :meta_description, :meta_keywords, :seo_title, :default_currency, :default, :supported_currencies, :facebook,
|
8
|
+
:twitter, :instagram, :default_locale, :customer_support_email, :default_country_id, :description,
|
9
|
+
:address, :contact_phone, :contact_email
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -4,8 +4,8 @@ module Spree
|
|
4
4
|
class VariantSerializer < BaseSerializer
|
5
5
|
set_type :variant
|
6
6
|
|
7
|
-
attributes :
|
8
|
-
:width, :depth, :is_master, :options_text
|
7
|
+
attributes :sku, :price, :currency, :display_price, :weight, :height,
|
8
|
+
:width, :depth, :is_master, :options_text
|
9
9
|
|
10
10
|
attribute :purchasable, &:purchasable?
|
11
11
|
attribute :in_stock, &:in_stock?
|
@@ -6,6 +6,10 @@ attributes *product_attributes
|
|
6
6
|
node(:display_price) { |p| p.display_price.to_s }
|
7
7
|
node(:has_variants, &:has_variants?)
|
8
8
|
node(:taxon_ids, &:taxon_ids)
|
9
|
+
node(:display_current_currency_price) do |product|
|
10
|
+
price = product.price_in(current_currency)
|
11
|
+
Spree::Money.new(price.amount, currency: current_currency).to_s
|
12
|
+
end
|
9
13
|
|
10
14
|
child master: :master do
|
11
15
|
extends 'spree/api/v1/variants/small'
|
data/config/routes.rb
CHANGED
@@ -152,6 +152,7 @@ Spree::Core::Engine.add_routes do
|
|
152
152
|
resource :account, controller: :account, only: %i[show]
|
153
153
|
|
154
154
|
namespace :account do
|
155
|
+
resources :addresses, controller: :addresses, only: %i[index create update]
|
155
156
|
resources :credit_cards, controller: :credit_cards, only: %i[index show]
|
156
157
|
resources :orders, controller: :orders, only: %i[index show]
|
157
158
|
end
|
@@ -161,6 +162,7 @@ Spree::Core::Engine.add_routes do
|
|
161
162
|
get '/order_status/:number', to: 'order_status#show', as: :order_status
|
162
163
|
resources :products, only: %i[index show]
|
163
164
|
resources :taxons, only: %i[index show], id: /.+/
|
165
|
+
get '/stores/:code', to: 'stores#show', as: :store
|
164
166
|
end
|
165
167
|
end
|
166
168
|
|
@@ -49,7 +49,167 @@ paths:
|
|
49
49
|
$ref: '#/components/responses/403Forbidden'
|
50
50
|
security:
|
51
51
|
- bearerAuth: []
|
52
|
+
post:
|
53
|
+
description: >-
|
54
|
+
Creates a new account
|
55
|
+
|
56
|
+
This endpoint requires [Spree Auth Devise](https://github.com/spree/spree_auth_devise) gem installed
|
57
|
+
tags:
|
58
|
+
- Account
|
59
|
+
operationId: 'Account Creation'
|
60
|
+
requestBody:
|
61
|
+
required: true
|
62
|
+
content:
|
63
|
+
application/vnd.api+json:
|
64
|
+
schema:
|
65
|
+
type: object
|
66
|
+
properties:
|
67
|
+
user:
|
68
|
+
type: object
|
69
|
+
properties:
|
70
|
+
email:
|
71
|
+
type: string
|
72
|
+
example: 'john@snow.org'
|
73
|
+
password:
|
74
|
+
type: string
|
75
|
+
example: 'spree123'
|
76
|
+
password_confirmation:
|
77
|
+
type: string
|
78
|
+
example: 'spree123'
|
79
|
+
responses:
|
80
|
+
'200':
|
81
|
+
description: ok
|
82
|
+
content:
|
83
|
+
application/vnd.api+json:
|
84
|
+
schema:
|
85
|
+
$ref: '#/components/schemas/Account'
|
86
|
+
'422':
|
87
|
+
description: Validation errors
|
88
|
+
content:
|
89
|
+
application/vnd.api+json:
|
90
|
+
schema:
|
91
|
+
$ref: '#/components/schemas/Error'
|
92
|
+
patch:
|
93
|
+
description: >-
|
94
|
+
Updates user account
|
52
95
|
|
96
|
+
This endpoint requires [Spree Auth Devise](https://github.com/spree/spree_auth_devise) gem installed
|
97
|
+
tags:
|
98
|
+
- Account
|
99
|
+
operationId: 'Account Updates'
|
100
|
+
requestBody:
|
101
|
+
required: true
|
102
|
+
content:
|
103
|
+
application/vnd.api+json:
|
104
|
+
schema:
|
105
|
+
type: object
|
106
|
+
properties:
|
107
|
+
user:
|
108
|
+
type: object
|
109
|
+
properties:
|
110
|
+
email:
|
111
|
+
type: string
|
112
|
+
example: 'john@snow.org'
|
113
|
+
password:
|
114
|
+
type: string
|
115
|
+
example: 'spree123'
|
116
|
+
password_confirmation:
|
117
|
+
type: string
|
118
|
+
example: 'spree123'
|
119
|
+
responses:
|
120
|
+
'200':
|
121
|
+
description: ok
|
122
|
+
content:
|
123
|
+
application/vnd.api+json:
|
124
|
+
schema:
|
125
|
+
$ref: '#/components/schemas/Account'
|
126
|
+
'422':
|
127
|
+
description: Validation errors
|
128
|
+
content:
|
129
|
+
application/vnd.api+json:
|
130
|
+
schema:
|
131
|
+
$ref: '#/components/schemas/Error'
|
132
|
+
security:
|
133
|
+
- bearerAuth: []
|
134
|
+
'/account/addresses':
|
135
|
+
get:
|
136
|
+
description: >-
|
137
|
+
Returns a list of Addresses for the signed in User
|
138
|
+
tags:
|
139
|
+
- Account
|
140
|
+
operationId: 'Addresses list'
|
141
|
+
responses:
|
142
|
+
'200':
|
143
|
+
description: Listing user addresses.
|
144
|
+
content:
|
145
|
+
application/vnd.api+json:
|
146
|
+
schema:
|
147
|
+
$ref: '#/components/schemas/AddressList'
|
148
|
+
'403':
|
149
|
+
$ref: '#/components/responses/403Forbidden'
|
150
|
+
security:
|
151
|
+
- bearerAuth: []
|
152
|
+
post:
|
153
|
+
description: >-
|
154
|
+
Create a new Address for the signed in User
|
155
|
+
tags:
|
156
|
+
- Account
|
157
|
+
operationId: 'Create Address'
|
158
|
+
requestBody:
|
159
|
+
required: true
|
160
|
+
content:
|
161
|
+
application/vnd.api+json:
|
162
|
+
schema:
|
163
|
+
type: object
|
164
|
+
properties:
|
165
|
+
address:
|
166
|
+
$ref: '#/components/schemas/AddressPayload'
|
167
|
+
responses:
|
168
|
+
'200':
|
169
|
+
description: Created Address.
|
170
|
+
content:
|
171
|
+
application/vnd.api+json:
|
172
|
+
schema:
|
173
|
+
$ref: '#/components/schemas/AddressList'
|
174
|
+
'403':
|
175
|
+
$ref: '#/components/responses/403Forbidden'
|
176
|
+
security:
|
177
|
+
- bearerAuth: []
|
178
|
+
'/account/addresses/{id}':
|
179
|
+
patch:
|
180
|
+
description: >-
|
181
|
+
Update selected Address for the signed in User
|
182
|
+
tags:
|
183
|
+
- Account
|
184
|
+
operationId: 'Update Address'
|
185
|
+
parameters:
|
186
|
+
- name: id
|
187
|
+
in: path
|
188
|
+
required: true
|
189
|
+
description: Selected Address for update
|
190
|
+
schema:
|
191
|
+
type: string
|
192
|
+
example: '1'
|
193
|
+
requestBody:
|
194
|
+
required: true
|
195
|
+
content:
|
196
|
+
application/vnd.api+json:
|
197
|
+
schema:
|
198
|
+
type: object
|
199
|
+
properties:
|
200
|
+
address:
|
201
|
+
$ref: '#/components/schemas/AddressPayload'
|
202
|
+
responses:
|
203
|
+
'200':
|
204
|
+
description: Updated Address.
|
205
|
+
content:
|
206
|
+
application/vnd.api+json:
|
207
|
+
schema:
|
208
|
+
$ref: '#/components/schemas/AddressList'
|
209
|
+
'403':
|
210
|
+
$ref: '#/components/responses/403Forbidden'
|
211
|
+
security:
|
212
|
+
- bearerAuth: []
|
53
213
|
'/account/credit_cards':
|
54
214
|
get:
|
55
215
|
description: >-
|
@@ -1125,6 +1285,14 @@ components:
|
|
1125
1285
|
company:
|
1126
1286
|
type: string
|
1127
1287
|
example: 'Google Inc.'
|
1288
|
+
AddressList:
|
1289
|
+
required:
|
1290
|
+
- data
|
1291
|
+
properties:
|
1292
|
+
data:
|
1293
|
+
type: array
|
1294
|
+
items:
|
1295
|
+
$ref: '#/components/schemas/Address'
|
1128
1296
|
Cart:
|
1129
1297
|
required:
|
1130
1298
|
- data
|
@@ -1291,6 +1459,18 @@ components:
|
|
1291
1459
|
display_tax_total:
|
1292
1460
|
type: string
|
1293
1461
|
example: '$10.00'
|
1462
|
+
pre_tax_item_amount:
|
1463
|
+
type: string
|
1464
|
+
example: '17.00'
|
1465
|
+
display_pre_tax_item_amount:
|
1466
|
+
type: string
|
1467
|
+
example: '$17.00'
|
1468
|
+
pre_tax_total:
|
1469
|
+
type: string
|
1470
|
+
example: '20.00'
|
1471
|
+
display_pre_tax_total:
|
1472
|
+
type: string
|
1473
|
+
example: '$20.00'
|
1294
1474
|
item_count:
|
1295
1475
|
type: number
|
1296
1476
|
example: 2
|
@@ -1503,6 +1683,12 @@ components:
|
|
1503
1683
|
display_discounted_amount:
|
1504
1684
|
type: string
|
1505
1685
|
example: '$125.00'
|
1686
|
+
pre_tax_amount:
|
1687
|
+
type: string
|
1688
|
+
example: '125.0'
|
1689
|
+
display_pre_tax_amount:
|
1690
|
+
type: string
|
1691
|
+
example: '$125.00'
|
1506
1692
|
promo_total:
|
1507
1693
|
type: string
|
1508
1694
|
example: '-5.0'
|
@@ -2003,10 +2189,6 @@ components:
|
|
2003
2189
|
VariantAttributes:
|
2004
2190
|
type: object
|
2005
2191
|
properties:
|
2006
|
-
name:
|
2007
|
-
type: string
|
2008
|
-
example: 'Example product'
|
2009
|
-
description: 'Product name'
|
2010
2192
|
sku:
|
2011
2193
|
type: string
|
2012
2194
|
example: 'SKU-1001'
|
@@ -2038,14 +2220,6 @@ components:
|
|
2038
2220
|
options_text:
|
2039
2221
|
type: string
|
2040
2222
|
example: 'Size: small, Color: red'
|
2041
|
-
slug:
|
2042
|
-
type: string
|
2043
|
-
example: 'example-product'
|
2044
|
-
description: 'Product slug'
|
2045
|
-
description:
|
2046
|
-
type: string
|
2047
|
-
example: 'Example description'
|
2048
|
-
description: 'Product description'
|
2049
2223
|
purchasable:
|
2050
2224
|
type: boolean
|
2051
2225
|
example: true
|
@@ -2218,6 +2392,11 @@ components:
|
|
2218
2392
|
$ref: '#/components/schemas/ShipmentAttributes'
|
2219
2393
|
relationships:
|
2220
2394
|
properties:
|
2395
|
+
stock_location:
|
2396
|
+
type: object
|
2397
|
+
properties:
|
2398
|
+
data:
|
2399
|
+
$ref: '#/components/schemas/Relation'
|
2221
2400
|
shipping_rates:
|
2222
2401
|
properties:
|
2223
2402
|
data:
|
@@ -2273,6 +2452,7 @@ components:
|
|
2273
2452
|
items:
|
2274
2453
|
oneOf:
|
2275
2454
|
- $ref: '#/components/schemas/ShippingRate'
|
2455
|
+
- $ref: '#/components/schemas/StockLocation'
|
2276
2456
|
EstimateShippingRatesList:
|
2277
2457
|
required:
|
2278
2458
|
- data
|
@@ -2327,6 +2507,20 @@ components:
|
|
2327
2507
|
type: integer
|
2328
2508
|
example: 1
|
2329
2509
|
description: 'ID of a Shipping Method. You will need this for the Checkout Update action'
|
2510
|
+
StockLocation:
|
2511
|
+
properties:
|
2512
|
+
id:
|
2513
|
+
type: string
|
2514
|
+
example: '1'
|
2515
|
+
type:
|
2516
|
+
type: string
|
2517
|
+
default: 'stock_location'
|
2518
|
+
attributes:
|
2519
|
+
type: object
|
2520
|
+
properties:
|
2521
|
+
name:
|
2522
|
+
type: string
|
2523
|
+
example: 'Main Warehouse'
|
2330
2524
|
Account:
|
2331
2525
|
required:
|
2332
2526
|
- data
|
@@ -6,7 +6,6 @@ module Spree
|
|
6
6
|
def self.included(klass)
|
7
7
|
klass.class_eval do
|
8
8
|
include CanCan::ControllerAdditions
|
9
|
-
include Spree::Core::ControllerHelpers::Auth
|
10
9
|
|
11
10
|
prepend_view_path Rails.root + 'app/views'
|
12
11
|
append_view_path File.expand_path('../../../app/views', File.dirname(__FILE__))
|
@@ -4,7 +4,7 @@ shared_context 'API v2 tokens' do
|
|
4
4
|
let(:headers_order_token) { { 'X-Spree-Order-Token' => order.token } }
|
5
5
|
end
|
6
6
|
|
7
|
-
[200, 201, 400, 404, 403, 422].each do |status_code|
|
7
|
+
[200, 201, 400, 401, 404, 403, 422].each do |status_code|
|
8
8
|
shared_examples "returns #{status_code} HTTP status" do
|
9
9
|
it "returns #{status_code}" do
|
10
10
|
expect(response.status).to eq(status_code)
|
@@ -48,6 +48,10 @@ shared_examples 'returns valid cart JSON' do
|
|
48
48
|
expect(json_response['data']).to have_attribute(:promo_total).with_value(order.promo_total.to_s)
|
49
49
|
expect(json_response['data']).to have_attribute(:display_promo_total).with_value(order.display_promo_total.to_s)
|
50
50
|
expect(json_response['data']).to have_attribute(:display_total).with_value(order.display_total.to_s)
|
51
|
+
expect(json_response['data']).to have_attribute(:pre_tax_item_amount).with_value(order.pre_tax_item_amount.to_s)
|
52
|
+
expect(json_response['data']).to have_attribute(:display_pre_tax_item_amount).with_value(order.display_pre_tax_item_amount.to_s)
|
53
|
+
expect(json_response['data']).to have_attribute(:pre_tax_total).with_value(order.pre_tax_total.to_s)
|
54
|
+
expect(json_response['data']).to have_attribute(:display_pre_tax_total).with_value(order.display_pre_tax_total.to_s)
|
51
55
|
expect(json_response['data']).to have_relationships(:user, :line_items, :variants, :billing_address, :shipping_address, :payments, :shipments, :promotions)
|
52
56
|
end
|
53
57
|
end
|
data/spree_api.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.email = ["ryan@spreecommerce.com"]
|
9
9
|
s.summary = %q{Spree's API}
|
10
10
|
s.description = %q{Spree's API}
|
11
|
-
s.homepage = '
|
11
|
+
s.homepage = 'https://spreecommerce.org'
|
12
12
|
s.license = 'BSD-3-Clause'
|
13
13
|
|
14
14
|
s.metadata = {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-rspec
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.
|
33
|
+
version: 4.2.0.rc1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.
|
40
|
+
version: 4.2.0.rc1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rabl
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- app/controllers/spree/api/v1/variants_controller.rb
|
134
134
|
- app/controllers/spree/api/v1/zones_controller.rb
|
135
135
|
- app/controllers/spree/api/v2/base_controller.rb
|
136
|
+
- app/controllers/spree/api/v2/storefront/account/addresses_controller.rb
|
136
137
|
- app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
|
137
138
|
- app/controllers/spree/api/v2/storefront/account/orders_controller.rb
|
138
139
|
- app/controllers/spree/api/v2/storefront/account_controller.rb
|
@@ -141,6 +142,7 @@ files:
|
|
141
142
|
- app/controllers/spree/api/v2/storefront/countries_controller.rb
|
142
143
|
- app/controllers/spree/api/v2/storefront/order_status_controller.rb
|
143
144
|
- app/controllers/spree/api/v2/storefront/products_controller.rb
|
145
|
+
- app/controllers/spree/api/v2/storefront/stores_controller.rb
|
144
146
|
- app/controllers/spree/api/v2/storefront/taxons_controller.rb
|
145
147
|
- app/helpers/spree/api/api_helpers.rb
|
146
148
|
- app/helpers/spree/api/v2/collection_options_helpers.rb
|
@@ -166,9 +168,11 @@ files:
|
|
166
168
|
- app/serializers/spree/v2/storefront/shipment_serializer.rb
|
167
169
|
- app/serializers/spree/v2/storefront/shipping_rate_serializer.rb
|
168
170
|
- app/serializers/spree/v2/storefront/state_serializer.rb
|
171
|
+
- app/serializers/spree/v2/storefront/stock_location_serializer.rb
|
169
172
|
- app/serializers/spree/v2/storefront/store_credit_event_serializer.rb
|
170
173
|
- app/serializers/spree/v2/storefront/store_credit_serializer.rb
|
171
174
|
- app/serializers/spree/v2/storefront/store_credit_type_serializer.rb
|
175
|
+
- app/serializers/spree/v2/storefront/store_serializer.rb
|
172
176
|
- app/serializers/spree/v2/storefront/taxon_image_serializer.rb
|
173
177
|
- app/serializers/spree/v2/storefront/taxon_serializer.rb
|
174
178
|
- app/serializers/spree/v2/storefront/taxonomy_serializer.rb
|
@@ -297,14 +301,14 @@ files:
|
|
297
301
|
- script/rails
|
298
302
|
- spec/fixtures/thinking-cat.jpg
|
299
303
|
- spree_api.gemspec
|
300
|
-
homepage:
|
304
|
+
homepage: https://spreecommerce.org
|
301
305
|
licenses:
|
302
306
|
- BSD-3-Clause
|
303
307
|
metadata:
|
304
308
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
305
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v4.
|
309
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.0.rc1
|
306
310
|
documentation_uri: https://guides.spreecommerce.org/
|
307
|
-
source_code_uri: https://github.com/spree/spree/tree/v4.
|
311
|
+
source_code_uri: https://github.com/spree/spree/tree/v4.2.0.rc1
|
308
312
|
post_install_message:
|
309
313
|
rdoc_options: []
|
310
314
|
require_paths:
|
@@ -316,11 +320,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
316
320
|
version: 2.5.0
|
317
321
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
318
322
|
requirements:
|
319
|
-
- - "
|
323
|
+
- - ">"
|
320
324
|
- !ruby/object:Gem::Version
|
321
|
-
version:
|
325
|
+
version: 1.3.1
|
322
326
|
requirements: []
|
323
|
-
rubygems_version: 3.1.
|
327
|
+
rubygems_version: 3.1.4
|
324
328
|
signing_key:
|
325
329
|
specification_version: 4
|
326
330
|
summary: Spree's API
|