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.

Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -0
  3. data/app/controllers/spree/api/addresses_controller.rb +1 -1
  4. data/app/controllers/spree/api/checkouts_controller.rb +4 -17
  5. data/app/controllers/spree/api/credit_cards_controller.rb +1 -1
  6. data/app/controllers/spree/api/images_controller.rb +1 -1
  7. data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
  8. data/app/controllers/spree/api/option_types_controller.rb +1 -1
  9. data/app/controllers/spree/api/option_values_controller.rb +1 -1
  10. data/app/controllers/spree/api/orders_controller.rb +1 -7
  11. data/app/controllers/spree/api/payments_controller.rb +1 -1
  12. data/app/controllers/spree/api/product_properties_controller.rb +1 -1
  13. data/app/controllers/spree/api/properties_controller.rb +1 -1
  14. data/app/controllers/spree/api/resource_controller.rb +1 -1
  15. data/app/controllers/spree/api/return_authorizations_controller.rb +1 -1
  16. data/app/controllers/spree/api/shipments_controller.rb +1 -1
  17. data/app/controllers/spree/api/stock_items_controller.rb +1 -1
  18. data/app/controllers/spree/api/stock_locations_controller.rb +1 -1
  19. data/app/controllers/spree/api/stores_controller.rb +1 -1
  20. data/app/controllers/spree/api/taxonomies_controller.rb +1 -1
  21. data/app/controllers/spree/api/taxons_controller.rb +1 -1
  22. data/app/controllers/spree/api/variants_controller.rb +1 -1
  23. data/app/controllers/spree/api/zones_controller.rb +1 -1
  24. data/app/helpers/spree/api/api_helpers.rb +1 -1
  25. data/app/views/spree/api/shared/_pagination.json.jbuilder +1 -1
  26. data/lib/spree/api/config.rb +9 -0
  27. data/lib/spree/api/engine.rb +4 -4
  28. data/lib/spree/api/responders.rb +1 -0
  29. data/lib/spree/api.rb +0 -7
  30. data/{app/models → lib}/spree/api_configuration.rb +0 -0
  31. data/openapi/.stoplight.yml +7 -0
  32. data/openapi/api.oas2.yml +6107 -0
  33. data/openapi/authentication.md +25 -0
  34. data/openapi/checkout-flow.md +50 -0
  35. data/openapi/errors.md +3 -0
  36. data/openapi/lint.yml +1 -0
  37. data/openapi/main.hub.yml +65 -0
  38. data/openapi/pagination.md +7 -0
  39. data/openapi/theme.css +0 -0
  40. data/spec/requests/spree/api/checkouts_controller_spec.rb +5 -33
  41. data/spec/requests/spree/api/classifications_controller_spec.rb +1 -1
  42. data/spec/requests/spree/api/orders_controller_spec.rb +3 -26
  43. data/spec/requests/spree/api/payments_controller_spec.rb +3 -3
  44. data/spec/requests/spree/api/stock_items_controller_spec.rb +5 -5
  45. data/spec/requests/spree/api/stock_locations_controller_spec.rb +4 -4
  46. metadata +16 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9041e899f4cd40c0426851ecab468e5b0e6799979026651d90ed71c68e9a33d2
4
- data.tar.gz: 6b6195d91d485815fc3e609c661efa408146b7ab49296c8db33987e568916ee4
3
+ metadata.gz: 6a9540c2c04dd060a437f426c70d637fd6bc681a625f66ab535f6f6940299071
4
+ data.tar.gz: 3ae3c6861ffb7a0d95bb3ebe3f3e01c7cfee7efe2b1b10b7ddb1bff09387230d
5
5
  SHA512:
6
- metadata.gz: 72241153b2007035f40f1869e76a276597580d11fe4d8b24bd37529a03520f799edfd9530a18677df79aeaafffa8f929d1f2bae1b9a320871b781b705c21a2f5
7
- data.tar.gz: dcb64f63cb2edd713a03bb3c971ed9de693d4e1af34bb3cb5746ed73b2294660ddb3805382587f10675f2ec71642ebb79f979373b21b7f03af8157bde6250067
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.update_attributes({ "#{@order_source}_attributes" => address_params })
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
- state = @order.state
80
- case state.to_sym
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
- massaged_params.fetch(:order, {}).permit(
95
- permitted_checkout_confirm_attributes
96
- )
82
+ # We current allow update requests without any parameters in them.
83
+ {}
97
84
  end
98
85
  end
99
86
 
@@ -18,7 +18,7 @@ module Spree
18
18
  end
19
19
 
20
20
  def update
21
- if @credit_card.update_attributes(credit_card_update_params)
21
+ if @credit_card.update(credit_card_update_params)
22
22
  respond_with(@credit_card, default_template: :show)
23
23
  else
24
24
  invalid_resource!(@credit_card)
@@ -21,7 +21,7 @@ module Spree
21
21
 
22
22
  def update
23
23
  @image = Spree::Image.accessible_by(current_ability, :update).find(params[:id])
24
- @image.update_attributes(image_params)
24
+ @image.update(image_params)
25
25
  respond_with(@image, default_template: :show)
26
26
  end
27
27
 
@@ -14,7 +14,7 @@ module Spree
14
14
  authorize! :update, inventory_unit.order
15
15
 
16
16
  inventory_unit.transaction do
17
- if inventory_unit.update_attributes(inventory_unit_params)
17
+ if inventory_unit.update(inventory_unit_params)
18
18
  fire
19
19
  render :show, status: 200
20
20
  else
@@ -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.update_attributes(option_type_params)
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.update_attributes(option_value_params)
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.update_attributes(payment_params)
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.update_attributes(product_property_params)
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.update_attributes(property_params)
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.update_attributes(permitted_resource_params)
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.update_attributes(return_authorization_params)
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)
@@ -146,7 +146,7 @@ module Spree
146
146
  end
147
147
 
148
148
  def update_shipment
149
- @shipment.update_attributes(shipment_params)
149
+ @shipment.update(shipment_params)
150
150
  @shipment.reload
151
151
  end
152
152
 
@@ -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.update_attributes(stock_item_params)
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.update_attributes(stock_location_params)
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)
@@ -24,7 +24,7 @@ module Spree
24
24
 
25
25
  def update
26
26
  authorize! :update, @store
27
- if @store.update_attributes(store_params)
27
+ if @store.update(store_params)
28
28
  respond_with(@store, status: 200, default_template: :show)
29
29
  else
30
30
  invalid_resource!(@store)
@@ -33,7 +33,7 @@ module Spree
33
33
 
34
34
  def update
35
35
  authorize! :update, taxonomy
36
- if taxonomy.update_attributes(taxonomy_params)
36
+ if taxonomy.update(taxonomy_params)
37
37
  respond_with(taxonomy, status: 200, default_template: :show)
38
38
  else
39
39
  invalid_resource!(taxonomy)
@@ -56,7 +56,7 @@ module Spree
56
56
 
57
57
  def update
58
58
  authorize! :update, taxon
59
- if taxon.update_attributes(taxon_params)
59
+ if taxon.update(taxon_params)
60
60
  respond_with(taxon, status: 200, default_template: :show)
61
61
  else
62
62
  invalid_resource!(taxon)
@@ -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.update_attributes(variant_params)
46
+ if @variant.update(variant_params)
47
47
  respond_with(@variant, status: 200, default_template: :show)
48
48
  else
49
49
  invalid_resource!(@product)
@@ -37,7 +37,7 @@ module Spree
37
37
 
38
38
  def update
39
39
  authorize! :update, zone
40
- if zone.update_attributes(zone_params)
40
+ if zone.update(zone_params)
41
41
  respond_with(zone, status: 200, default_template: :show)
42
42
  else
43
43
  invalid_resource!(zone)
@@ -177,7 +177,7 @@ module Spree
177
177
  ]
178
178
 
179
179
  def variant_attributes
180
- if @current_user_roles && @current_user_roles.include?("admin")
180
+ if @current_user_roles&.include?("admin")
181
181
  @@variant_attributes + [:cost_price]
182
182
  else
183
183
  @@variant_attributes
@@ -4,4 +4,4 @@ json.count pagination.count
4
4
  json.total_count pagination.total_count
5
5
  json.current_page pagination.current_page
6
6
  json.pages pagination.total_pages
7
- json.per_page pagination.current_per_page
7
+ json.per_page pagination.limit_value
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spree/api_configuration'
4
+
5
+ module Spree
6
+ module Api
7
+ Config = Spree::ApiConfiguration.new
8
+ end
9
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/engine'
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 "spree.api.environment", before: :load_config_initializers do |_app|
12
- Spree::Api::Config = Spree::ApiConfiguration.new
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
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'responders'
3
4
  require 'spree/api/responders/rabl_template'
4
5
 
5
6
  module Spree
data/lib/spree/api.rb CHANGED
@@ -2,11 +2,4 @@
2
2
 
3
3
  require 'spree/core'
4
4
 
5
- require 'responders'
6
-
7
- module Spree
8
- module Api
9
- end
10
- end
11
-
12
5
  require 'spree/api/engine'
File without changes
@@ -0,0 +1,7 @@
1
+ stoplight: '1.0'
2
+ environments:
3
+ default:
4
+ host: 'http://todos.stoplight.io'
5
+ todosApiKey: 123
6
+ staging: {}
7
+ production: {}