spree_api 3.7.14.1 → 4.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spree_api might be problematic. Click here for more details.

Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/app/controllers/spree/api/base_controller.rb +3 -3
  4. data/app/controllers/spree/api/v1/addresses_controller.rb +2 -2
  5. data/app/controllers/spree/api/v1/countries_controller.rb +2 -2
  6. data/app/controllers/spree/api/v1/credit_cards_controller.rb +2 -2
  7. data/app/controllers/spree/api/v1/images_controller.rb +3 -3
  8. data/app/controllers/spree/api/v1/inventory_units_controller.rb +2 -2
  9. data/app/controllers/spree/api/v1/option_types_controller.rb +4 -4
  10. data/app/controllers/spree/api/v1/option_values_controller.rb +3 -3
  11. data/app/controllers/spree/api/v1/payments_controller.rb +2 -2
  12. data/app/controllers/spree/api/v1/product_properties_controller.rb +4 -4
  13. data/app/controllers/spree/api/v1/properties_controller.rb +4 -4
  14. data/app/controllers/spree/api/v1/return_authorizations_controller.rb +4 -4
  15. data/app/controllers/spree/api/v1/shipments_controller.rb +3 -3
  16. data/app/controllers/spree/api/v1/states_controller.rb +3 -3
  17. data/app/controllers/spree/api/v1/stock_items_controller.rb +2 -2
  18. data/app/controllers/spree/api/v1/stock_locations_controller.rb +5 -4
  19. data/app/controllers/spree/api/v1/stock_movements_controller.rb +3 -3
  20. data/app/controllers/spree/api/v1/stores_controller.rb +4 -4
  21. data/app/controllers/spree/api/v1/taxonomies_controller.rb +3 -3
  22. data/app/controllers/spree/api/v1/taxons_controller.rb +5 -5
  23. data/app/controllers/spree/api/v1/users_controller.rb +3 -3
  24. data/app/controllers/spree/api/v1/variants_controller.rb +3 -3
  25. data/app/controllers/spree/api/v1/zones_controller.rb +3 -3
  26. data/app/controllers/spree/api/v2/base_controller.rb +1 -6
  27. data/app/controllers/spree/api/v2/storefront/account/credit_cards_controller.rb +1 -1
  28. data/app/controllers/spree/api/v2/storefront/countries_controller.rb +2 -1
  29. data/app/controllers/spree/api/v2/storefront/order_status_controller.rb +0 -6
  30. data/app/controllers/spree/api/v2/storefront/products_controller.rb +1 -1
  31. data/app/controllers/spree/api/v2/storefront/taxons_controller.rb +1 -1
  32. data/app/views/spree/api/errors/{gateway_error.v1.rabl → gateway_error.rabl} +0 -0
  33. data/app/views/spree/api/errors/{invalid_api_key.v1.rabl → invalid_api_key.rabl} +0 -0
  34. data/app/views/spree/api/errors/{invalid_resource.v1.rabl → invalid_resource.rabl} +0 -0
  35. data/app/views/spree/api/errors/{must_specify_api_key.v1.rabl → must_specify_api_key.rabl} +0 -0
  36. data/app/views/spree/api/errors/{not_found.v1.rabl → not_found.rabl} +0 -0
  37. data/app/views/spree/api/errors/{unauthorized.v1.rabl → unauthorized.rabl} +0 -0
  38. data/app/views/spree/api/v1/addresses/{show.v1.rabl → show.rabl} +0 -0
  39. data/app/views/spree/api/v1/adjustments/{show.v1.rabl → show.rabl} +0 -0
  40. data/app/views/spree/api/v1/countries/{index.v1.rabl → index.rabl} +0 -0
  41. data/app/views/spree/api/v1/countries/{show.v1.rabl → show.rabl} +0 -0
  42. data/app/views/spree/api/v1/credit_cards/{index.v1.rabl → index.rabl} +0 -0
  43. data/app/views/spree/api/v1/credit_cards/{show.v1.rabl → show.rabl} +0 -0
  44. data/app/views/spree/api/v1/customer_returns/{index.v1.rabl → index.rabl} +0 -0
  45. data/app/views/spree/api/v1/images/{index.v1.rabl → index.rabl} +0 -0
  46. data/app/views/spree/api/v1/images/{new.v1.rabl → new.rabl} +0 -0
  47. data/app/views/spree/api/v1/images/{show.v1.rabl → show.rabl} +0 -0
  48. data/app/views/spree/api/v1/line_items/{new.v1.rabl → new.rabl} +0 -0
  49. data/app/views/spree/api/v1/line_items/{show.v1.rabl → show.rabl} +0 -0
  50. data/app/views/spree/api/v1/option_types/{index.v1.rabl → index.rabl} +0 -0
  51. data/app/views/spree/api/v1/option_types/{new.v1.rabl → new.rabl} +0 -0
  52. data/app/views/spree/api/v1/option_types/{show.v1.rabl → show.rabl} +0 -0
  53. data/app/views/spree/api/v1/option_values/{index.v1.rabl → index.rabl} +0 -0
  54. data/app/views/spree/api/v1/option_values/{new.v1.rabl → new.rabl} +0 -0
  55. data/app/views/spree/api/v1/option_values/{show.v1.rabl → show.rabl} +0 -0
  56. data/app/views/spree/api/v1/orders/{address.v1.rabl → address.rabl} +0 -0
  57. data/app/views/spree/api/v1/orders/{canceled.v1.rabl → canceled.rabl} +0 -0
  58. data/app/views/spree/api/v1/orders/{cart.v1.rabl → cart.rabl} +0 -0
  59. data/app/views/spree/api/v1/orders/{complete.v1.rabl → complete.rabl} +0 -0
  60. data/app/views/spree/api/v1/orders/{could_not_apply_coupon.v1.rabl → could_not_apply_coupon.rabl} +0 -0
  61. data/app/views/spree/api/v1/orders/{could_not_transition.v1.rabl → could_not_transition.rabl} +0 -0
  62. data/app/views/spree/api/v1/orders/{index.v1.rabl → index.rabl} +0 -0
  63. data/app/views/spree/api/v1/orders/{insufficient_quantity.v1.rabl → insufficient_quantity.rabl} +0 -0
  64. data/app/views/spree/api/v1/orders/{invalid_shipping_method.v1.rabl → invalid_shipping_method.rabl} +0 -0
  65. data/app/views/spree/api/v1/orders/{mine.v1.rabl → mine.rabl} +0 -0
  66. data/app/views/spree/api/v1/orders/{order.v1.rabl → order.rabl} +0 -0
  67. data/app/views/spree/api/v1/orders/{payment.v1.rabl → payment.rabl} +0 -0
  68. data/app/views/spree/api/v1/orders/{show.v1.rabl → show.rabl} +0 -0
  69. data/app/views/spree/api/v1/payments/{credit_over_limit.v1.rabl → credit_over_limit.rabl} +0 -0
  70. data/app/views/spree/api/v1/payments/{index.v1.rabl → index.rabl} +0 -0
  71. data/app/views/spree/api/v1/payments/{new.v1.rabl → new.rabl} +0 -0
  72. data/app/views/spree/api/v1/payments/{show.v1.rabl → show.rabl} +0 -0
  73. data/app/views/spree/api/v1/payments/{update_forbidden.v1.rabl → update_forbidden.rabl} +0 -0
  74. data/app/views/spree/api/v1/product_properties/{index.v1.rabl → index.rabl} +0 -0
  75. data/app/views/spree/api/v1/product_properties/{new.v1.rabl → new.rabl} +0 -0
  76. data/app/views/spree/api/v1/product_properties/{show.v1.rabl → show.rabl} +0 -0
  77. data/app/views/spree/api/v1/products/{index.v1.rabl → index.rabl} +0 -0
  78. data/app/views/spree/api/v1/products/{new.v1.rabl → new.rabl} +0 -0
  79. data/app/views/spree/api/v1/products/{product.v1.rabl → product.rabl} +0 -0
  80. data/app/views/spree/api/v1/products/{show.v1.rabl → show.rabl} +0 -0
  81. data/app/views/spree/api/v1/promotions/{handler.v1.rabl → handler.rabl} +0 -0
  82. data/app/views/spree/api/v1/promotions/{show.v1.rabl → show.rabl} +0 -0
  83. data/app/views/spree/api/v1/properties/{index.v1.rabl → index.rabl} +0 -0
  84. data/app/views/spree/api/v1/properties/{new.v1.rabl → new.rabl} +0 -0
  85. data/app/views/spree/api/v1/properties/{show.v1.rabl → show.rabl} +0 -0
  86. data/app/views/spree/api/v1/reimbursements/{index.v1.rabl → index.rabl} +0 -0
  87. data/app/views/spree/api/v1/return_authorizations/{index.v1.rabl → index.rabl} +0 -0
  88. data/app/views/spree/api/v1/return_authorizations/{new.v1.rabl → new.rabl} +0 -0
  89. data/app/views/spree/api/v1/return_authorizations/{show.v1.rabl → show.rabl} +0 -0
  90. data/app/views/spree/api/v1/shared/{stock_location_required.v1.rabl → stock_location_required.rabl} +0 -0
  91. data/app/views/spree/api/v1/shipments/{big.v1.rabl → big.rabl} +0 -0
  92. data/app/views/spree/api/v1/shipments/{cannot_ready_shipment.v1.rabl → cannot_ready_shipment.rabl} +0 -0
  93. data/app/views/spree/api/v1/shipments/{mine.v1.rabl → mine.rabl} +0 -0
  94. data/app/views/spree/api/v1/shipments/{show.v1.rabl → show.rabl} +0 -0
  95. data/app/views/spree/api/v1/shipments/{small.v1.rabl → small.rabl} +0 -0
  96. data/app/views/spree/api/v1/shipping_rates/{show.v1.rabl → show.rabl} +0 -0
  97. data/app/views/spree/api/v1/states/{index.v1.rabl → index.rabl} +0 -0
  98. data/app/views/spree/api/v1/states/{show.v1.rabl → show.rabl} +0 -0
  99. data/app/views/spree/api/v1/stock_items/{index.v1.rabl → index.rabl} +0 -0
  100. data/app/views/spree/api/v1/stock_items/{show.v1.rabl → show.rabl} +0 -0
  101. data/app/views/spree/api/v1/stock_locations/{index.v1.rabl → index.rabl} +0 -0
  102. data/app/views/spree/api/v1/stock_locations/{show.v1.rabl → show.rabl} +0 -0
  103. data/app/views/spree/api/v1/stock_movements/{index.v1.rabl → index.rabl} +0 -0
  104. data/app/views/spree/api/v1/stock_movements/{show.v1.rabl → show.rabl} +0 -0
  105. data/app/views/spree/api/v1/stores/{index.v1.rabl → index.rabl} +0 -0
  106. data/app/views/spree/api/v1/stores/{show.v1.rabl → show.rabl} +0 -0
  107. data/app/views/spree/api/v1/tags/{index.v1.rabl → index.rabl} +0 -0
  108. data/app/views/spree/api/v1/taxonomies/{index.v1.rabl → index.rabl} +0 -0
  109. data/app/views/spree/api/v1/taxonomies/{nested.v1.rabl → nested.rabl} +0 -0
  110. data/app/views/spree/api/v1/taxonomies/{new.v1.rabl → new.rabl} +0 -0
  111. data/app/views/spree/api/v1/taxonomies/{show.v1.rabl → show.rabl} +0 -0
  112. data/app/views/spree/api/v1/taxons/{index.v1.rabl → index.rabl} +0 -0
  113. data/app/views/spree/api/v1/taxons/{new.v1.rabl → new.rabl} +0 -0
  114. data/app/views/spree/api/v1/taxons/{show.v1.rabl → show.rabl} +0 -0
  115. data/app/views/spree/api/v1/taxons/{taxons.v1.rabl → taxons.rabl} +0 -0
  116. data/app/views/spree/api/v1/users/{index.v1.rabl → index.rabl} +0 -0
  117. data/app/views/spree/api/v1/users/{new.v1.rabl → new.rabl} +0 -0
  118. data/app/views/spree/api/v1/users/{show.v1.rabl → show.rabl} +0 -0
  119. data/app/views/spree/api/v1/variants/{big.v1.rabl → big.rabl} +0 -0
  120. data/app/views/spree/api/v1/variants/{index.v1.rabl → index.rabl} +0 -0
  121. data/app/views/spree/api/v1/variants/{new.v1.rabl → new.rabl} +0 -0
  122. data/app/views/spree/api/v1/variants/{show.v1.rabl → show.rabl} +0 -0
  123. data/app/views/spree/api/v1/variants/{small.v1.rabl → small.rabl} +0 -0
  124. data/app/views/spree/api/v1/zones/{index.v1.rabl → index.rabl} +0 -0
  125. data/app/views/spree/api/v1/zones/{show.v1.rabl → show.rabl} +0 -0
  126. data/config/initializers/doorkeeper.rb +12 -0
  127. data/config/initializers/rabl_rails6_fix.rb +16 -0
  128. data/config/routes.rb +0 -2
  129. data/docs/v2/storefront/index.yaml +36 -31
  130. data/lib/spree/api/engine.rb +0 -19
  131. data/lib/spree/api/testing_support/v2/base.rb +1 -1
  132. data/lib/spree_api.rb +0 -1
  133. data/spree_api.gemspec +2 -3
  134. metadata +108 -126
  135. data/app/controllers/spree/api/v1/tags_controller.rb +0 -28
  136. data/app/models/doorkeeper/access_grant_decorator.rb +0 -3
  137. data/app/models/doorkeeper/access_token_decorator.rb +0 -3
  138. data/app/models/doorkeeper/application_decorator.rb +0 -3
  139. data/config/initializers/metal_load_paths.rb +0 -1
@@ -5,8 +5,6 @@ module Spree
5
5
  class OrderStatusController < ::Spree::Api::V2::BaseController
6
6
  include Spree::Api::V2::Storefront::OrderConcern
7
7
 
8
- before_action :ensure_order_token
9
-
10
8
  def show
11
9
  render_serialized_payload { serialize_resource(resource) }
12
10
  end
@@ -27,10 +25,6 @@ module Spree
27
25
  def resource_serializer
28
26
  Spree::Api::Dependencies.storefront_cart_serializer.constantize
29
27
  end
30
-
31
- def ensure_order_token
32
- raise ActiveRecord::RecordNotFound unless order_token.present?
33
- end
34
28
  end
35
29
  end
36
30
  end
@@ -44,7 +44,7 @@ module Spree
44
44
  end
45
45
 
46
46
  def scope
47
- Spree::Product.accessible_by(current_ability, :read).includes(scope_includes)
47
+ Spree::Product.accessible_by(current_ability, :show).includes(scope_includes)
48
48
  end
49
49
 
50
50
  def scope_includes
@@ -40,7 +40,7 @@ module Spree
40
40
  end
41
41
 
42
42
  def scope
43
- Spree::Taxon.accessible_by(current_ability, :read).includes(scope_includes)
43
+ Spree::Taxon.accessible_by(current_ability, :show).includes(scope_includes)
44
44
  end
45
45
 
46
46
  def scope_includes
@@ -18,3 +18,15 @@ Doorkeeper.configure do
18
18
 
19
19
  access_token_methods :from_bearer_authorization, :from_access_token_param
20
20
  end
21
+
22
+ Doorkeeper::AccessGrant.class_eval do
23
+ self.table_name = 'spree_oauth_access_grants'
24
+ end
25
+
26
+ Doorkeeper::AccessToken.class_eval do
27
+ self.table_name = 'spree_oauth_access_tokens'
28
+ end
29
+
30
+ Doorkeeper::Application.class_eval do
31
+ self.table_name = 'spree_oauth_applications'
32
+ end
@@ -0,0 +1,16 @@
1
+ # https://github.com/nesquena/rabl/pull/723
2
+ module ActionView
3
+ module Template::Handlers
4
+ class Rabl
5
+ class_attribute :default_format, default: :json
6
+
7
+ def self.call(_template, source)
8
+ %{ ::Rabl::Engine.new(#{source.inspect}).
9
+ apply(self, assigns.merge(local_assigns)).
10
+ render }
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ ActionView::Template.register_template_handler :rabl, ActionView::Template::Handlers::Rabl
data/config/routes.rb CHANGED
@@ -122,8 +122,6 @@ Spree::Core::Engine.add_routes do
122
122
  resources :stock_items, only: [:index, :update, :destroy]
123
123
  resources :stores
124
124
 
125
- resources :tags, only: :index
126
-
127
125
  put '/classifications', to: 'classifications#update', as: :classifications
128
126
  get '/taxons/products', to: 'taxons#products', as: :taxon_products
129
127
  end
@@ -12,7 +12,15 @@ info:
12
12
  intefaces either in JavaScript frameworks or native mobile libraries.
13
13
  </p>
14
14
  <p>
15
- Please read our introduction to the API v2 [insert link here]
15
+ Please read our <a href="https://guides.spreecommerce.org/api/v2/">
16
+ introduction to the API v2
17
+ </a>
18
+ </p>
19
+ <p>
20
+ Download our
21
+ <a href="https://github.com/spree/spree-storefront-api-v2-js-sdk">
22
+ official JavaScript & TypeScript SDK
23
+ </a>
16
24
  </p>
17
25
  <p>
18
26
  <a href="https://raw.githubusercontent.com/spree/spree/master/api/docs/v2/storefront/index.yaml" target="_blank" rel="noopener">
@@ -154,8 +162,6 @@ paths:
154
162
  - $ref: '#/components/parameters/OrderParam'
155
163
  - $ref: '#/components/parameters/CartIncludeParam'
156
164
  - $ref: '#/components/parameters/SparseFieldsParam'
157
- security:
158
- - orderToken: []
159
165
  '/cart':
160
166
  post:
161
167
  description: >-
@@ -345,7 +351,7 @@ paths:
345
351
  operationId: 'Apply Coupon Code'
346
352
  responses:
347
353
  '200':
348
- description: Cuopon code was applied successfully
354
+ description: Coupon code was applied successfully
349
355
  content:
350
356
  application/vnd.api+json:
351
357
  schema:
@@ -375,15 +381,15 @@ paths:
375
381
 
376
382
  '/cart/remove_coupon_code/{coupon_code}':
377
383
  delete:
378
- description: Removes a coupon code from the Cart
384
+ description: Removes a coupon code from the Cart. If no `coupon_code` parameter is passed will remove all applied coupon codes.
379
385
  tags:
380
386
  - Cart
381
387
  operationId: 'Remove Coupon Code'
382
388
  parameters:
383
389
  - name: coupon_code
384
390
  in: path
385
- required: true
386
- description: Coupon code applied to Order
391
+ required: false
392
+ description: Selected Coupon code for removal
387
393
  schema:
388
394
  type: string
389
395
  example: 'DISCOUNT10'
@@ -450,28 +456,24 @@ paths:
450
456
  order: {
451
457
  email: 'john@snow.org',
452
458
  bill_address_attributes: {
453
- {
454
- firstname: 'John',
455
- lastname: 'Snow',
456
- address1: '7735 Old Georgetown Road',
457
- city: 'Bethesda',
458
- phone: '3014445002',
459
- zipcode: '20814',
460
- state_name: 'MD',
461
- country_iso: 'US'
462
- }
459
+ firstname: 'John',
460
+ lastname: 'Snow',
461
+ address1: '7735 Old Georgetown Road',
462
+ city: 'Bethesda',
463
+ phone: '3014445002',
464
+ zipcode: '20814',
465
+ state_name: 'MD',
466
+ country_iso: 'US'
463
467
  },
464
468
  ship_address_attributes: {
465
- {
466
- firstname: 'John',
467
- lastname: 'Snow',
468
- address1: '7735 Old Georgetown Road',
469
- city: 'Bethesda',
470
- phone: '3014445002',
471
- zipcode: '20814',
472
- state_name: 'MD',
473
- country_iso: 'US'
474
- }
469
+ firstname: 'John',
470
+ lastname: 'Snow',
471
+ address1: '7735 Old Georgetown Road',
472
+ city: 'Bethesda',
473
+ phone: '3014445002',
474
+ zipcode: '20814',
475
+ state_name: 'MD',
476
+ country_iso: 'US'
475
477
  }
476
478
  }
477
479
  </pre>
@@ -493,9 +495,12 @@ paths:
493
495
  <br />
494
496
  <pre>
495
497
  order: {
496
- shipments_attributes: {
497
- '0' => { selected_shipping_rate_id: 1, id: 1}
498
- }
498
+ shipments_attributes: [
499
+ {
500
+ id: 1,
501
+ selected_shipping_rate_id: 1
502
+ }
503
+ ]
499
504
  }
500
505
  </pre>
501
506
  <br />
@@ -517,7 +522,7 @@ paths:
517
522
  ]
518
523
  },
519
524
  payment_source: {
520
- '1' => {
525
+ 1: {
521
526
  number: '4111111111111111',
522
527
  month: '01',
523
528
  year: '2022',
@@ -1,5 +1,4 @@
1
1
  require 'rails/engine'
2
- require 'versioncake'
3
2
 
4
3
  module Spree
5
4
  module Api
@@ -17,17 +16,6 @@ module Spree
17
16
  config.json_engine = ActiveSupport::JSON
18
17
  end
19
18
 
20
- initializer 'spree.api.versioncake' do |_app|
21
- VersionCake.setup do |config|
22
- config.resources do |r|
23
- r.resource %r{.*}, [], [], [1, 2]
24
- end
25
-
26
- config.missing_version = 1
27
- config.extraction_strategy = :http_header
28
- end
29
- end
30
-
31
19
  # sets the manifests / assets to be precompiled, even when initialize_on_precompile is false
32
20
  initializer 'spree.assets.precompile', group: :all do |app|
33
21
  app.config.assets.precompile += %w[
@@ -44,13 +32,6 @@ module Spree
44
32
  Migrations.new(config, engine_name).check
45
33
  end
46
34
 
47
- def self.activate
48
- Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')) do |c|
49
- Rails.configuration.cache_classes ? require(c) : load(c)
50
- end
51
- end
52
- config.to_prepare &method(:activate).to_proc
53
-
54
35
  def self.root
55
36
  @root ||= Pathname.new(File.expand_path('../../..', __dir__))
56
37
  end
@@ -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, 401, 404, 403, 422].each do |status_code|
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)
data/lib/spree_api.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'spree/api'
2
2
  require 'spree/api/responders'
3
- require 'versioncake'
4
3
  require 'fast_jsonapi'
5
4
  require 'doorkeeper'
data/spree_api.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.homepage = 'http://spreecommerce.org'
10
10
  s.license = 'BSD-3-Clause'
11
11
 
12
- s.required_ruby_version = '>= 2.3.3'
12
+ s.required_ruby_version = '>= 2.5.0'
13
13
 
14
14
  s.files = `git ls-files`.split($\).reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
15
15
  s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -20,8 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency 'jsonapi-rspec'
21
21
 
22
22
  s.add_dependency 'spree_core', s.version
23
- s.add_dependency 'rabl', '~> 0.13.1'
24
- s.add_dependency 'versioncake', '~> 3.4.0'
23
+ s.add_dependency 'rabl', '~> 0.14.1'
25
24
  s.add_dependency 'fast_jsonapi', '~> 1.5'
26
25
  s.add_dependency 'doorkeeper', '~> 5.0'
27
26
  end