spree_api 4.0.9 → 4.1.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.
Potentially problematic release.
This version of spree_api might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/controllers/concerns/spree/api/v2/storefront/order_concern.rb +1 -1
- data/app/controllers/spree/api/v1/checkouts_controller.rb +0 -6
- data/app/controllers/spree/api/v2/base_controller.rb +2 -19
- data/app/controllers/spree/api/v2/storefront/account/orders_controller.rb +2 -2
- data/app/controllers/spree/api/v2/storefront/cart_controller.rb +1 -1
- data/app/controllers/spree/api/v2/storefront/checkout_controller.rb +3 -6
- data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +1 -1
- data/app/helpers/spree/api/api_helpers.rb +2 -1
- data/app/models/spree/api_dependencies.rb +1 -11
- data/app/serializers/spree/v2/storefront/cart_serializer.rb +5 -9
- data/app/serializers/spree/v2/storefront/line_item_serializer.rb +1 -2
- data/app/serializers/spree/v2/storefront/payment_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/shipment_serializer.rb +1 -3
- data/app/serializers/spree/v2/storefront/store_credit_serializer.rb +1 -1
- data/app/serializers/spree/v2/storefront/taxon_serializer.rb +1 -1
- data/config/initializers/doorkeeper.rb +0 -2
- data/config/routes.rb +1 -3
- data/docs/v2/storefront/index.yaml +0 -26
- data/lib/spree/api/testing_support/v2/base.rb +1 -1
- data/lib/spree/api/testing_support/v2/current_order.rb +0 -6
- data/spree_api.gemspec +3 -10
- metadata +11 -20
- data/app/controllers/spree/api/v2/storefront/account/addresses_controller.rb +0 -77
- data/app/controllers/spree/api/v2/storefront/stores_controller.rb +0 -27
- data/app/serializers/spree/v2/storefront/stock_location_serializer.rb +0 -11
- data/app/serializers/spree/v2/storefront/store_credit_category_serializer.rb +0 -11
- data/app/serializers/spree/v2/storefront/store_serializer.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 778714449abf4f277278f0bc8f878d98241965f805f733cb0b909ec2013ff521
|
4
|
+
data.tar.gz: e655b291e623b62e931745d3dfafc3ea27d885a36f7e1d5797065fe02f789610
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfa5ee6b7d215c1a96b573f6b775295b136e930d018bdd5e8f7bd8746bbbf35aae824aa91ddd427718050a7190fa2cebbddaeb1b0afcf34c568b2b66b6766932
|
7
|
+
data.tar.gz: 29395a003c49523a5ce4daaa5d8c2a0025d88005682b6f3cea62cf450e2e1a4e021952f6f6996609276e9a657d7a45c3027df6b3c84b7646af39986189285cd6
|
@@ -27,7 +27,7 @@ module Spree
|
|
27
27
|
|
28
28
|
def find_spree_current_order
|
29
29
|
Spree::Api::Dependencies.storefront_current_order_finder.constantize.new.execute(
|
30
|
-
store:
|
30
|
+
store: current_store,
|
31
31
|
user: spree_current_user,
|
32
32
|
token: order_token,
|
33
33
|
currency: current_currency
|
@@ -2,14 +2,8 @@ module Spree
|
|
2
2
|
module Api
|
3
3
|
module V1
|
4
4
|
class CheckoutsController < Spree::Api::BaseController
|
5
|
-
before_action :associate_user, only: :update
|
6
5
|
before_action :load_order_with_lock, only: [:next, :advance, :update]
|
7
6
|
|
8
|
-
include Spree::Core::ControllerHelpers::Auth
|
9
|
-
include Spree::Core::ControllerHelpers::Order
|
10
|
-
# This before_action comes from Spree::Core::ControllerHelpers::Order
|
11
|
-
skip_before_action :set_current_order
|
12
|
-
|
13
7
|
def next
|
14
8
|
authorize! :update, @order, order_token
|
15
9
|
@order.next!
|
@@ -4,9 +4,9 @@ module Spree
|
|
4
4
|
class BaseController < ActionController::API
|
5
5
|
include CanCan::ControllerAdditions
|
6
6
|
include Spree::Core::ControllerHelpers::StrongParameters
|
7
|
+
include Spree::Core::ControllerHelpers::Store
|
7
8
|
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
|
8
9
|
rescue_from CanCan::AccessDenied, with: :access_denied
|
9
|
-
rescue_from Spree::Core::GatewayError, with: :gateway_error
|
10
10
|
|
11
11
|
def content_type
|
12
12
|
Spree::Api::Config[:api_v2_content_type]
|
@@ -51,17 +51,8 @@ module Spree
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def spree_current_store
|
55
|
-
@spree_current_store ||= Spree::Store.current(request.env['SERVER_NAME'])
|
56
|
-
end
|
57
|
-
|
58
54
|
def spree_current_user
|
59
|
-
|
60
|
-
return @spree_current_user if @spree_current_user
|
61
|
-
|
62
|
-
doorkeeper_authorize!
|
63
|
-
|
64
|
-
@spree_current_user ||= Spree.user_class.find_by(id: doorkeeper_token.resource_owner_id)
|
55
|
+
@spree_current_user ||= Spree.user_class.find_by(id: doorkeeper_token.resource_owner_id) if doorkeeper_token
|
65
56
|
end
|
66
57
|
|
67
58
|
def spree_authorize!(action, subject, *args)
|
@@ -110,10 +101,6 @@ module Spree
|
|
110
101
|
fields.presence
|
111
102
|
end
|
112
103
|
|
113
|
-
def current_currency
|
114
|
-
spree_current_store.default_currency || Spree::Config[:currency]
|
115
|
-
end
|
116
|
-
|
117
104
|
def record_not_found
|
118
105
|
render_error_payload(I18n.t(:resource_not_found, scope: 'spree.api'), 404)
|
119
106
|
end
|
@@ -121,10 +108,6 @@ module Spree
|
|
121
108
|
def access_denied(exception)
|
122
109
|
render_error_payload(exception.message, 403)
|
123
110
|
end
|
124
|
-
|
125
|
-
def gateway_error(exception)
|
126
|
-
render_error_payload(exception.message)
|
127
|
-
end
|
128
111
|
end
|
129
112
|
end
|
130
113
|
end
|
@@ -35,11 +35,11 @@ module Spree
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def collection_serializer
|
38
|
-
Spree::Api::Dependencies.
|
38
|
+
Spree::Api::Dependencies.storefront_cart_serializer.constantize
|
39
39
|
end
|
40
40
|
|
41
41
|
def resource_serializer
|
42
|
-
Spree::Api::Dependencies.
|
42
|
+
Spree::Api::Dependencies.storefront_cart_serializer.constantize
|
43
43
|
end
|
44
44
|
|
45
45
|
def collection_finder
|
@@ -65,11 +65,7 @@ module Spree
|
|
65
65
|
def shipping_rates
|
66
66
|
result = shipping_rates_service.call(order: spree_current_order)
|
67
67
|
|
68
|
-
|
69
|
-
render_serialized_payload { serialize_shipping_rates(result.value) }
|
70
|
-
else
|
71
|
-
render_error_payload(result.error)
|
72
|
-
end
|
68
|
+
render_serialized_payload { serialize_shipping_rates(result.value) }
|
73
69
|
end
|
74
70
|
|
75
71
|
def payment_methods
|
@@ -125,7 +121,8 @@ module Spree
|
|
125
121
|
def serialize_shipping_rates(shipments)
|
126
122
|
shipping_rates_serializer.new(
|
127
123
|
shipments,
|
128
|
-
include: [:shipping_rates,
|
124
|
+
include: [:shipping_rates],
|
125
|
+
params: { show_rates: true }
|
129
126
|
).serializable_hash
|
130
127
|
end
|
131
128
|
end
|
@@ -161,7 +161,8 @@ module Spree
|
|
161
161
|
|
162
162
|
@@store_attributes = [
|
163
163
|
:id, :name, :url, :meta_description, :meta_keywords, :seo_title,
|
164
|
-
:mail_from_address, :default_currency, :code, :default
|
164
|
+
:mail_from_address, :default_currency, :code, :default,
|
165
|
+
:facebook, :twitter, :instagram
|
165
166
|
]
|
166
167
|
|
167
168
|
@@tag_attributes = [:id, :name]
|
@@ -13,9 +13,7 @@ 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
|
17
|
-
:storefront_store_serializer, :storefront_address_serializer, :storefront_order_serializer,
|
18
|
-
:storefront_account_create_address_service, :storefront_account_update_address_service, :storefront_address_finder
|
16
|
+
:storefront_cart_update_service, :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer
|
19
17
|
].freeze
|
20
18
|
|
21
19
|
attr_accessor *INJECTION_POINTS
|
@@ -50,12 +48,7 @@ module Spree
|
|
50
48
|
@storefront_checkout_remove_store_credit_service = Spree::Dependencies.checkout_remove_store_credit_service
|
51
49
|
@storefront_checkout_get_shipping_rates_service = Spree::Dependencies.checkout_get_shipping_rates_service
|
52
50
|
|
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
|
-
|
57
51
|
# serializers
|
58
|
-
@storefront_address_serializer = 'Spree::V2::Storefront::AddressSerializer'
|
59
52
|
@storefront_cart_serializer = 'Spree::V2::Storefront::CartSerializer'
|
60
53
|
@storefront_credit_card_serializer = 'Spree::V2::Storefront::CreditCardSerializer'
|
61
54
|
@storefront_country_serializer = 'Spree::V2::Storefront::CountrySerializer'
|
@@ -65,8 +58,6 @@ module Spree
|
|
65
58
|
@storefront_payment_method_serializer = 'Spree::V2::Storefront::PaymentMethodSerializer'
|
66
59
|
@storefront_product_serializer = 'Spree::V2::Storefront::ProductSerializer'
|
67
60
|
@storefront_estimated_shipment_serializer = 'Spree::V2::Storefront::EstimatedShippingRateSerializer'
|
68
|
-
@storefront_store_serializer = 'Spree::V2::Storefront::StoreSerializer'
|
69
|
-
@storefront_order_serializer = 'Spree::V2::Storefront::CartSerializer'
|
70
61
|
|
71
62
|
# sorters
|
72
63
|
@storefront_order_sorter = Spree::Dependencies.order_sorter
|
@@ -76,7 +67,6 @@ module Spree
|
|
76
67
|
@storefront_collection_paginator = Spree::Dependencies.collection_paginator
|
77
68
|
|
78
69
|
# finders
|
79
|
-
@storefront_address_finder = Spree::Dependencies.address_finder
|
80
70
|
@storefront_country_finder = Spree::Dependencies.country_finder
|
81
71
|
@storefront_current_order_finder = Spree::Dependencies.current_order_finder
|
82
72
|
@storefront_completed_order_finder = Spree::Dependencies.completed_order_finder
|
@@ -8,9 +8,7 @@ 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
|
12
|
-
:pre_tax_item_amount, :display_pre_tax_item_amount, :pre_tax_total, :display_pre_tax_total,
|
13
|
-
:shipment_state, :payment_state
|
11
|
+
:promo_total, :display_promo_total, :item_count, :special_instructions, :display_total
|
14
12
|
|
15
13
|
has_many :line_items
|
16
14
|
has_many :variants
|
@@ -22,14 +20,12 @@ module Spree
|
|
22
20
|
|
23
21
|
belongs_to :user
|
24
22
|
belongs_to :billing_address,
|
25
|
-
|
26
|
-
|
27
|
-
record_type: :address
|
23
|
+
id_method_name: :bill_address_id,
|
24
|
+
serializer: :address
|
28
25
|
|
29
26
|
belongs_to :shipping_address,
|
30
|
-
|
31
|
-
|
32
|
-
record_type: :address
|
27
|
+
id_method_name: :ship_address_id,
|
28
|
+
serializer: :address
|
33
29
|
end
|
34
30
|
end
|
35
31
|
end
|
@@ -9,8 +9,7 @@ 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
|
13
|
-
:pre_tax_amount, :display_pre_tax_amount
|
12
|
+
:included_tax_total, :display_included_tax_total
|
14
13
|
|
15
14
|
belongs_to :variant
|
16
15
|
end
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
class TaxonSerializer < BaseSerializer
|
5
5
|
set_type :taxon
|
6
6
|
|
7
|
-
attributes :name, :pretty_name, :permalink, :seo_title, :
|
7
|
+
attributes :name, :pretty_name, :permalink, :seo_title, :meta_title, :meta_description,
|
8
8
|
:meta_keywords, :left, :right, :position, :depth, :updated_at
|
9
9
|
|
10
10
|
attribute :is_root, &:root?
|
@@ -3,8 +3,6 @@ Doorkeeper.configure do
|
|
3
3
|
use_refresh_token
|
4
4
|
api_only
|
5
5
|
|
6
|
-
skip_client_authentication_for_password_grant { true } if defined?(skip_client_authentication_for_password_grant)
|
7
|
-
|
8
6
|
resource_owner_authenticator { current_spree_user }
|
9
7
|
|
10
8
|
resource_owner_from_credentials do
|
data/config/routes.rb
CHANGED
@@ -152,7 +152,6 @@ 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]
|
156
155
|
resources :credit_cards, controller: :credit_cards, only: %i[index show]
|
157
156
|
resources :orders, controller: :orders, only: %i[index show]
|
158
157
|
end
|
@@ -161,8 +160,7 @@ Spree::Core::Engine.add_routes do
|
|
161
160
|
get '/countries/:iso', to: 'countries#show', as: :country
|
162
161
|
get '/order_status/:number', to: 'order_status#show', as: :order_status
|
163
162
|
resources :products, only: %i[index show]
|
164
|
-
resources :taxons, only: %i[index show]
|
165
|
-
get '/stores/:code', to: 'stores#show', as: :store
|
163
|
+
resources :taxons, only: %i[index show]
|
166
164
|
end
|
167
165
|
end
|
168
166
|
|
@@ -1123,14 +1123,6 @@ components:
|
|
1123
1123
|
company:
|
1124
1124
|
type: string
|
1125
1125
|
example: 'Google Inc.'
|
1126
|
-
AddressList:
|
1127
|
-
required:
|
1128
|
-
- data
|
1129
|
-
properties:
|
1130
|
-
data:
|
1131
|
-
type: array
|
1132
|
-
items:
|
1133
|
-
$ref: '#/components/schemas/Address'
|
1134
1126
|
Cart:
|
1135
1127
|
required:
|
1136
1128
|
- data
|
@@ -1297,18 +1289,6 @@ components:
|
|
1297
1289
|
display_tax_total:
|
1298
1290
|
type: string
|
1299
1291
|
example: '$10.00'
|
1300
|
-
pre_tax_item_amount:
|
1301
|
-
type: string
|
1302
|
-
example: '17.00'
|
1303
|
-
display_pre_tax_item_amount:
|
1304
|
-
type: string
|
1305
|
-
example: '$17.00'
|
1306
|
-
pre_tax_total:
|
1307
|
-
type: string
|
1308
|
-
example: '20.00'
|
1309
|
-
display_pre_tax_total:
|
1310
|
-
type: string
|
1311
|
-
example: '$20.00'
|
1312
1292
|
item_count:
|
1313
1293
|
type: number
|
1314
1294
|
example: 2
|
@@ -1521,12 +1501,6 @@ components:
|
|
1521
1501
|
display_discounted_amount:
|
1522
1502
|
type: string
|
1523
1503
|
example: '$125.00'
|
1524
|
-
pre_tax_amount:
|
1525
|
-
type: string
|
1526
|
-
example: '125.0'
|
1527
|
-
display_pre_tax_amount:
|
1528
|
-
type: string
|
1529
|
-
example: '$125.00'
|
1530
1504
|
promo_total:
|
1531
1505
|
type: string
|
1532
1506
|
example: '-5.0'
|
@@ -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,
|
7
|
+
[200, 201, 400, 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)
|
@@ -27,8 +27,6 @@ shared_examples 'returns valid cart JSON' do
|
|
27
27
|
expect(json_response['data']).to have_type('cart')
|
28
28
|
expect(json_response['data']).to have_attribute(:number).with_value(order.number)
|
29
29
|
expect(json_response['data']).to have_attribute(:state).with_value(order.state)
|
30
|
-
expect(json_response['data']).to have_attribute(:payment_state).with_value(order.payment_state)
|
31
|
-
expect(json_response['data']).to have_attribute(:shipment_state).with_value(order.shipment_state)
|
32
30
|
expect(json_response['data']).to have_attribute(:token).with_value(order.token)
|
33
31
|
expect(json_response['data']).to have_attribute(:total).with_value(order.total.to_s)
|
34
32
|
expect(json_response['data']).to have_attribute(:item_total).with_value(order.item_total.to_s)
|
@@ -50,10 +48,6 @@ shared_examples 'returns valid cart JSON' do
|
|
50
48
|
expect(json_response['data']).to have_attribute(:promo_total).with_value(order.promo_total.to_s)
|
51
49
|
expect(json_response['data']).to have_attribute(:display_promo_total).with_value(order.display_promo_total.to_s)
|
52
50
|
expect(json_response['data']).to have_attribute(:display_total).with_value(order.display_total.to_s)
|
53
|
-
expect(json_response['data']).to have_attribute(:pre_tax_item_amount).with_value(order.pre_tax_item_amount.to_s)
|
54
|
-
expect(json_response['data']).to have_attribute(:display_pre_tax_item_amount).with_value(order.display_pre_tax_item_amount.to_s)
|
55
|
-
expect(json_response['data']).to have_attribute(:pre_tax_total).with_value(order.pre_tax_total.to_s)
|
56
|
-
expect(json_response['data']).to have_attribute(:display_pre_tax_total).with_value(order.display_pre_tax_total.to_s)
|
57
51
|
expect(json_response['data']).to have_relationships(:user, :line_items, :variants, :billing_address, :shipping_address, :payments, :shipments, :promotions)
|
58
52
|
end
|
59
53
|
end
|
data/spree_api.gemspec
CHANGED
@@ -2,27 +2,20 @@
|
|
2
2
|
require_relative '../core/lib/spree/core/version.rb'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name = "spree_api"
|
6
|
-
s.version = Spree.version
|
7
5
|
s.authors = ["Ryan Bigg"]
|
8
6
|
s.email = ["ryan@spreecommerce.com"]
|
9
|
-
s.summary = %q{Spree's API}
|
10
7
|
s.description = %q{Spree's API}
|
8
|
+
s.summary = %q{Spree's API}
|
11
9
|
s.homepage = 'http://spreecommerce.org'
|
12
10
|
s.license = 'BSD-3-Clause'
|
13
11
|
|
14
|
-
s.metadata = {
|
15
|
-
"bug_tracker_uri" => "https://github.com/spree/spree/issues",
|
16
|
-
"changelog_uri" => "https://github.com/spree/spree/releases/tag/v#{s.version}",
|
17
|
-
"documentation_uri" => "https://guides.spreecommerce.org/",
|
18
|
-
"source_code_uri" => "https://github.com/spree/spree/tree/v#{s.version}",
|
19
|
-
}
|
20
|
-
|
21
12
|
s.required_ruby_version = '>= 2.5.0'
|
22
13
|
|
23
14
|
s.files = `git ls-files`.split($\).reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
|
24
15
|
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
s.name = "spree_api"
|
25
17
|
s.require_paths = ["lib"]
|
18
|
+
s.version = Spree.version
|
26
19
|
|
27
20
|
s.add_development_dependency 'jsonapi-rspec'
|
28
21
|
|
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.0.
|
4
|
+
version: 4.1.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-31 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.0.
|
33
|
+
version: 4.1.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.0.
|
40
|
+
version: 4.1.0.rc1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rabl
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,7 +133,6 @@ 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
|
137
136
|
- app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb
|
138
137
|
- app/controllers/spree/api/v2/storefront/account/orders_controller.rb
|
139
138
|
- app/controllers/spree/api/v2/storefront/account_controller.rb
|
@@ -142,7 +141,6 @@ files:
|
|
142
141
|
- app/controllers/spree/api/v2/storefront/countries_controller.rb
|
143
142
|
- app/controllers/spree/api/v2/storefront/order_status_controller.rb
|
144
143
|
- app/controllers/spree/api/v2/storefront/products_controller.rb
|
145
|
-
- app/controllers/spree/api/v2/storefront/stores_controller.rb
|
146
144
|
- app/controllers/spree/api/v2/storefront/taxons_controller.rb
|
147
145
|
- app/helpers/spree/api/api_helpers.rb
|
148
146
|
- app/helpers/spree/api/v2/collection_options_helpers.rb
|
@@ -168,12 +166,9 @@ files:
|
|
168
166
|
- app/serializers/spree/v2/storefront/shipment_serializer.rb
|
169
167
|
- app/serializers/spree/v2/storefront/shipping_rate_serializer.rb
|
170
168
|
- app/serializers/spree/v2/storefront/state_serializer.rb
|
171
|
-
- app/serializers/spree/v2/storefront/stock_location_serializer.rb
|
172
|
-
- app/serializers/spree/v2/storefront/store_credit_category_serializer.rb
|
173
169
|
- app/serializers/spree/v2/storefront/store_credit_event_serializer.rb
|
174
170
|
- app/serializers/spree/v2/storefront/store_credit_serializer.rb
|
175
171
|
- app/serializers/spree/v2/storefront/store_credit_type_serializer.rb
|
176
|
-
- app/serializers/spree/v2/storefront/store_serializer.rb
|
177
172
|
- app/serializers/spree/v2/storefront/taxon_image_serializer.rb
|
178
173
|
- app/serializers/spree/v2/storefront/taxon_serializer.rb
|
179
174
|
- app/serializers/spree/v2/storefront/taxonomy_serializer.rb
|
@@ -305,12 +300,8 @@ files:
|
|
305
300
|
homepage: http://spreecommerce.org
|
306
301
|
licenses:
|
307
302
|
- BSD-3-Clause
|
308
|
-
metadata:
|
309
|
-
|
310
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v4.0.9
|
311
|
-
documentation_uri: https://guides.spreecommerce.org/
|
312
|
-
source_code_uri: https://github.com/spree/spree/tree/v4.0.9
|
313
|
-
post_install_message:
|
303
|
+
metadata: {}
|
304
|
+
post_install_message:
|
314
305
|
rdoc_options: []
|
315
306
|
require_paths:
|
316
307
|
- lib
|
@@ -321,12 +312,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
321
312
|
version: 2.5.0
|
322
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
323
314
|
requirements:
|
324
|
-
- - "
|
315
|
+
- - ">"
|
325
316
|
- !ruby/object:Gem::Version
|
326
|
-
version:
|
317
|
+
version: 1.3.1
|
327
318
|
requirements: []
|
328
|
-
rubygems_version: 3.
|
329
|
-
signing_key:
|
319
|
+
rubygems_version: 3.0.3
|
320
|
+
signing_key:
|
330
321
|
specification_version: 4
|
331
322
|
summary: Spree's API
|
332
323
|
test_files: []
|
@@ -1,77 +0,0 @@
|
|
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
|
@@ -1,27 +0,0 @@
|
|
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
|
@@ -1,13 +0,0 @@
|
|
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
|