solidus_api 2.9.6 → 2.10.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_api might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/app/controllers/spree/api/addresses_controller.rb +1 -1
- data/app/controllers/spree/api/checkouts_controller.rb +4 -17
- data/app/controllers/spree/api/credit_cards_controller.rb +1 -1
- data/app/controllers/spree/api/images_controller.rb +1 -1
- data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
- data/app/controllers/spree/api/option_types_controller.rb +1 -1
- data/app/controllers/spree/api/option_values_controller.rb +1 -1
- data/app/controllers/spree/api/orders_controller.rb +1 -7
- data/app/controllers/spree/api/payments_controller.rb +1 -1
- data/app/controllers/spree/api/product_properties_controller.rb +1 -1
- data/app/controllers/spree/api/properties_controller.rb +1 -1
- data/app/controllers/spree/api/resource_controller.rb +1 -1
- data/app/controllers/spree/api/return_authorizations_controller.rb +1 -1
- data/app/controllers/spree/api/shipments_controller.rb +1 -1
- data/app/controllers/spree/api/stock_items_controller.rb +1 -1
- data/app/controllers/spree/api/stock_locations_controller.rb +1 -1
- data/app/controllers/spree/api/stores_controller.rb +1 -1
- data/app/controllers/spree/api/taxonomies_controller.rb +1 -1
- data/app/controllers/spree/api/taxons_controller.rb +1 -1
- data/app/controllers/spree/api/variants_controller.rb +1 -1
- data/app/controllers/spree/api/zones_controller.rb +1 -1
- data/app/helpers/spree/api/api_helpers.rb +1 -1
- data/app/views/spree/api/shared/_pagination.json.jbuilder +1 -1
- data/lib/spree/api/config.rb +9 -0
- data/lib/spree/api/engine.rb +4 -4
- data/lib/spree/api/responders.rb +1 -0
- data/lib/spree/api.rb +0 -7
- data/{app/models → lib}/spree/api_configuration.rb +0 -0
- data/openapi/.stoplight.yml +7 -0
- data/openapi/api.oas2.yml +6107 -0
- data/openapi/authentication.md +25 -0
- data/openapi/checkout-flow.md +50 -0
- data/openapi/errors.md +3 -0
- data/openapi/lint.yml +1 -0
- data/openapi/main.hub.yml +65 -0
- data/openapi/pagination.md +7 -0
- data/openapi/theme.css +0 -0
- data/spec/requests/spree/api/checkouts_controller_spec.rb +5 -33
- data/spec/requests/spree/api/classifications_controller_spec.rb +1 -1
- data/spec/requests/spree/api/orders_controller_spec.rb +3 -26
- data/spec/requests/spree/api/payments_controller_spec.rb +3 -3
- data/spec/requests/spree/api/stock_items_controller_spec.rb +5 -5
- data/spec/requests/spree/api/stock_locations_controller_spec.rb +4 -4
- metadata +16 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a9540c2c04dd060a437f426c70d637fd6bc681a625f66ab535f6f6940299071
|
4
|
+
data.tar.gz: 3ae3c6861ffb7a0d95bb3ebe3f3e01c7cfee7efe2b1b10b7ddb1bff09387230d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f08e8ffc5e36133c43d57082f717817b78c462cafbd2ba87019835d156d92df88c7c875b6739808744d9c0dca86939f38ac7792802ecf72e53831271d7d8830d
|
7
|
+
data.tar.gz: d74356f3fd6de4f1d540ed6232e0bc91f9b1ec5999ed278e4f107357ca26411d4a0bfdca28b5585d856205fe96db1ce631b73f5bc46e2747f537bf596363e2ce
|
data/README.md
CHANGED
@@ -9,3 +9,17 @@ Run the API tests:
|
|
9
9
|
```bash
|
10
10
|
bundle exec rspec
|
11
11
|
```
|
12
|
+
|
13
|
+
## Documentation
|
14
|
+
|
15
|
+
The API documentation is in the [openapi](https://github.com/solidusio/solidus/tree/master/api/openapi)
|
16
|
+
directory. It follows the OpenAPI specification and it is hosted on
|
17
|
+
[Stoplight](https://solidus.docs.stoplight.io/).
|
18
|
+
|
19
|
+
If you want to contribute, you can use [Stoplight Studio](https://stoplight.io/p/studio),
|
20
|
+
an OpenAPI editor, to edit the files visually, and copy-paste the
|
21
|
+
resulting code into the `openapi` directory.
|
22
|
+
|
23
|
+
CircleCI automatically syncs our Git repo with Stoplight when a PR is
|
24
|
+
merged, and automatically publishes a new version on Stoplight when
|
25
|
+
a new Solidus version is released.
|
@@ -15,7 +15,7 @@ module Spree
|
|
15
15
|
authorize! :update, @order, order_token
|
16
16
|
find_address
|
17
17
|
|
18
|
-
if @order.
|
18
|
+
if @order.update({ "#{@order_source}_attributes" => address_params })
|
19
19
|
@address = @order.send(@order_source)
|
20
20
|
respond_with(@address, default_template: :show)
|
21
21
|
else
|
@@ -76,24 +76,11 @@ module Spree
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def update_params
|
79
|
-
|
80
|
-
|
81
|
-
when :cart, :address
|
82
|
-
massaged_params.fetch(:order, {}).permit(
|
83
|
-
permitted_checkout_address_attributes
|
84
|
-
)
|
85
|
-
when :delivery
|
86
|
-
massaged_params.require(:order).permit(
|
87
|
-
permitted_checkout_delivery_attributes
|
88
|
-
)
|
89
|
-
when :payment
|
90
|
-
massaged_params.require(:order).permit(
|
91
|
-
permitted_checkout_payment_attributes
|
92
|
-
)
|
79
|
+
if update_params = massaged_params[:order]
|
80
|
+
update_params.permit(permitted_checkout_attributes)
|
93
81
|
else
|
94
|
-
|
95
|
-
|
96
|
-
)
|
82
|
+
# We current allow update requests without any parameters in them.
|
83
|
+
{}
|
97
84
|
end
|
98
85
|
end
|
99
86
|
|
@@ -29,7 +29,7 @@ module Spree
|
|
29
29
|
|
30
30
|
def update
|
31
31
|
@option_type = Spree::OptionType.accessible_by(current_ability, :update).find(params[:id])
|
32
|
-
if @option_type.
|
32
|
+
if @option_type.update(option_type_params)
|
33
33
|
render :show
|
34
34
|
else
|
35
35
|
invalid_resource!(@option_type)
|
@@ -29,7 +29,7 @@ module Spree
|
|
29
29
|
|
30
30
|
def update
|
31
31
|
@option_value = scope.accessible_by(current_ability, :update).find(params[:id])
|
32
|
-
if @option_value.
|
32
|
+
if @option_value.update(option_value_params)
|
33
33
|
render :show
|
34
34
|
else
|
35
35
|
invalid_resource!(@option_value)
|
@@ -131,13 +131,7 @@ module Spree
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def normalize_params
|
134
|
-
if params[:order][:payments]
|
135
|
-
payments_params = params[:order].delete(:payments)
|
136
|
-
params[:order][:payments_attributes] = payments_params.map do |payment_params|
|
137
|
-
payment_params[:source_attributes] = payment_params.delete(:source) if payment_params[:source].present?
|
138
|
-
payment_params
|
139
|
-
end
|
140
|
-
end
|
134
|
+
params[:order][:payments_attributes] = params[:order].delete(:payments) if params[:order][:payments]
|
141
135
|
params[:order][:shipments_attributes] = params[:order].delete(:shipments) if params[:order][:shipments]
|
142
136
|
params[:order][:line_items_attributes] = params[:order].delete(:line_items) if params[:order][:line_items]
|
143
137
|
params[:order][:ship_address_attributes] = params[:order].delete(:ship_address) if params[:order][:ship_address].present?
|
@@ -31,7 +31,7 @@ module Spree
|
|
31
31
|
authorize! params[:action], @payment
|
32
32
|
if !@payment.pending?
|
33
33
|
render 'update_forbidden', status: 403
|
34
|
-
elsif @payment.
|
34
|
+
elsif @payment.update(payment_params)
|
35
35
|
respond_with(@payment, default_template: :show)
|
36
36
|
else
|
37
37
|
invalid_resource!(@payment)
|
@@ -38,7 +38,7 @@ module Spree
|
|
38
38
|
def update
|
39
39
|
if @product_property
|
40
40
|
authorize! :update, @product_property
|
41
|
-
@product_property.
|
41
|
+
@product_property.update(product_property_params)
|
42
42
|
respond_with(@product_property, status: 200, default_template: :show)
|
43
43
|
else
|
44
44
|
invalid_resource!(@product_property)
|
@@ -39,7 +39,7 @@ module Spree
|
|
39
39
|
def update
|
40
40
|
if @property
|
41
41
|
authorize! :update, @property
|
42
|
-
@property.
|
42
|
+
@property.update(property_params)
|
43
43
|
respond_with(@property, status: 200, default_template: :show)
|
44
44
|
else
|
45
45
|
invalid_resource!(@property)
|
@@ -43,7 +43,7 @@ class Spree::Api::ResourceController < Spree::Api::BaseController
|
|
43
43
|
def update
|
44
44
|
authorize! :update, @object
|
45
45
|
|
46
|
-
if @object.
|
46
|
+
if @object.update(permitted_resource_params)
|
47
47
|
respond_with(@object, status: 200, default_template: :show)
|
48
48
|
else
|
49
49
|
invalid_resource!(@object)
|
@@ -50,7 +50,7 @@ module Spree
|
|
50
50
|
|
51
51
|
def update
|
52
52
|
@return_authorization = @order.return_authorizations.accessible_by(current_ability, :update).find(params[:id])
|
53
|
-
if @return_authorization.
|
53
|
+
if @return_authorization.update(return_authorization_params)
|
54
54
|
respond_with(@return_authorization, default_template: :show)
|
55
55
|
else
|
56
56
|
invalid_resource!(@return_authorization)
|
@@ -40,7 +40,7 @@ module Spree
|
|
40
40
|
adjustment -= @stock_item.count_on_hand if params[:stock_item][:force]
|
41
41
|
|
42
42
|
Spree::StockItem.transaction do
|
43
|
-
if @stock_item.
|
43
|
+
if @stock_item.update(stock_item_params)
|
44
44
|
adjust_stock_item_count_on_hand(adjustment)
|
45
45
|
respond_with(@stock_item, status: 200, default_template: :show)
|
46
46
|
else
|
@@ -33,7 +33,7 @@ module Spree
|
|
33
33
|
|
34
34
|
def update
|
35
35
|
authorize! :update, stock_location
|
36
|
-
if stock_location.
|
36
|
+
if stock_location.update(stock_location_params)
|
37
37
|
respond_with(stock_location, status: 200, default_template: :show)
|
38
38
|
else
|
39
39
|
invalid_resource!(stock_location)
|
@@ -43,7 +43,7 @@ module Spree
|
|
43
43
|
|
44
44
|
def update
|
45
45
|
@variant = scope.accessible_by(current_ability, :update).find(params[:id])
|
46
|
-
if @variant.
|
46
|
+
if @variant.update(variant_params)
|
47
47
|
respond_with(@variant, status: 200, default_template: :show)
|
48
48
|
else
|
49
49
|
invalid_resource!(@product)
|
data/lib/spree/api/engine.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'spree/api/config'
|
4
4
|
|
5
5
|
module Spree
|
6
6
|
module Api
|
@@ -8,9 +8,9 @@ module Spree
|
|
8
8
|
isolate_namespace Spree
|
9
9
|
engine_name 'spree_api'
|
10
10
|
|
11
|
-
initializer
|
12
|
-
|
13
|
-
end
|
11
|
+
# Leave initializer empty for backwards-compatability. Other apps
|
12
|
+
# might still rely on this event.
|
13
|
+
initializer "spree.api.environment", before: :load_config_initializers do; end
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/spree/api/responders.rb
CHANGED
data/lib/spree/api.rb
CHANGED
File without changes
|