solidus_api 4.3.5 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/api/coupon_codes_controller.rb +2 -2
  3. data/app/controllers/spree/api/orders_controller.rb +7 -2
  4. data/app/controllers/spree/api/promotions_controller.rb +1 -1
  5. data/app/controllers/spree/api/variants_controller.rb +1 -1
  6. data/app/views/spree/api/credit_cards/index.json.jbuilder +1 -1
  7. data/app/views/spree/api/images/index.json.jbuilder +1 -1
  8. data/app/views/spree/api/line_items/_line_item.json.jbuilder +2 -2
  9. data/app/views/spree/api/option_types/index.json.jbuilder +1 -1
  10. data/app/views/spree/api/option_values/index.json.jbuilder +1 -1
  11. data/app/views/spree/api/orders/_big.json.jbuilder +6 -6
  12. data/app/views/spree/api/orders/index.json.jbuilder +1 -1
  13. data/app/views/spree/api/orders/mine.json.jbuilder +1 -1
  14. data/app/views/spree/api/products/_product.json.jbuilder +1 -1
  15. data/app/views/spree/api/products/index.json.jbuilder +1 -1
  16. data/app/views/spree/api/shipments/_big.json.jbuilder +2 -2
  17. data/app/views/spree/api/shipments/_small.json.jbuilder +2 -2
  18. data/app/views/spree/api/shipments/mine.json.jbuilder +1 -1
  19. data/app/views/spree/api/shipments/show.json.jbuilder +1 -1
  20. data/app/views/spree/api/stock_items/index.json.jbuilder +1 -1
  21. data/app/views/spree/api/stock_locations/index.json.jbuilder +1 -1
  22. data/app/views/spree/api/stock_movements/index.json.jbuilder +1 -1
  23. data/app/views/spree/api/taxonomies/_nested.json.jbuilder +1 -1
  24. data/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder +1 -1
  25. data/app/views/spree/api/taxonomies/index.json.jbuilder +1 -1
  26. data/app/views/spree/api/taxons/_taxons.json.jbuilder +1 -1
  27. data/app/views/spree/api/taxons/index.json.jbuilder +1 -1
  28. data/app/views/spree/api/users/index.json.jbuilder +1 -1
  29. data/app/views/spree/api/variants/_big.json.jbuilder +1 -1
  30. data/app/views/spree/api/variants/_small.json.jbuilder +1 -1
  31. data/app/views/spree/api/variants/index.json.jbuilder +1 -1
  32. data/app/views/spree/api/zones/index.json.jbuilder +1 -1
  33. data/lib/spree/api_configuration.rb +13 -6
  34. data/openapi/solidus-api.oas.yml +0 -4
  35. data/solidus_api.gemspec +1 -1
  36. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f429e34d41a7311e140db04b7ea766989bef6ec5671a4e81cd2b780480426243
4
- data.tar.gz: e28e7b8b6953878a147d86ea67abacbca26dc3afc396ba9284761665967a5212
3
+ metadata.gz: fe76fd029542c6286ca86c8d4089615e5b67aeb3e8aec8aeb679f512b8894ad7
4
+ data.tar.gz: d761e4866ec82e74ac65d20bf2d3615b57aa5fc633d04c77fe801410b9a4d11a
5
5
  SHA512:
6
- metadata.gz: ba7b566efd83c5d2e5dd6669f7bf59a682688d15d0b0e9c1ddc0cd895481adea23902fc4b3824f43aa6d7fc9387360ba2127369c8896909eb9e5687e6128344c
7
- data.tar.gz: 195c1e2d0ff19e7c3693444e96788b6abe61a9933118ceeed96f6fb9c1ce4c2d934d0a81cf8e45dd5ccd644e050d49fa456c429056cf1a376275f31ede5ca40c
6
+ metadata.gz: f77b0d4ed1076e28076fb293fd2cad3d84926ef75c75fcb801f407761c3f5ed1f6827804dfed17ea2fc19145124a0f7a1ec8d05f8c7ee015607ee932e7c6bd65
7
+ data.tar.gz: 3125e5d524dc8e1601304cb897bf701443e529cbe3719ca5480fc007c74f67eb100260dfd1be080c9d0c20a4fa0f582764d0afc127112aadb6e07715b1f4d366
@@ -10,7 +10,7 @@ module Spree
10
10
  authorize! :update, @order, order_token
11
11
 
12
12
  @order.coupon_code = params[:coupon_code]
13
- @handler = Spree::Config.coupon_code_handler_class.new(@order).apply
13
+ @handler = Spree::Config.promotions.coupon_code_handler_class.new(@order).apply
14
14
 
15
15
  if @handler.successful?
16
16
  render 'spree/api/promotions/handler', status: 200
@@ -24,7 +24,7 @@ module Spree
24
24
  authorize! :update, @order, order_token
25
25
 
26
26
  @order.coupon_code = params[:id]
27
- @handler = Spree::Config.coupon_code_handler_class.new(@order).remove
27
+ @handler = Spree::Config.promotions.coupon_code_handler_class.new(@order).remove
28
28
 
29
29
  if @handler.successful?
30
30
  render 'spree/api/promotions/handler', status: 200
@@ -46,8 +46,13 @@ module Spree
46
46
 
47
47
  def empty
48
48
  authorize! :update, @order, order_token
49
- @order.empty!
50
- respond_with(@order, default_template: :show)
49
+
50
+ if @order.complete?
51
+ invalid_resource!(@order)
52
+ else
53
+ @order.empty!
54
+ respond_with(@order, default_template: :show)
55
+ end
51
56
  end
52
57
 
53
58
  def index
@@ -13,7 +13,7 @@ module Spree
13
13
  private
14
14
 
15
15
  def load_promotion
16
- @promotion = Spree::Promotion.with_coupon_code(params[:id]) || Spree::Promotion.find(params[:id])
16
+ @promotion = Spree::Config.promotions.promotion_finder_class.by_code_or_id(params[:id])
17
17
  end
18
18
  end
19
19
  end
@@ -28,7 +28,7 @@ module Spree
28
28
  @variants =
29
29
  if params[:variant_search_term]
30
30
  Spree::Config.variant_search_class.new(
31
- params[:variant_search_term], scope: scope
31
+ params[:variant_search_term], scope:
32
32
  ).results.includes(include_list)
33
33
  else
34
34
  scope.includes(include_list).ransack(params[:q]).result
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.credit_cards(@credit_cards) do |credit_card|
4
- json.partial!("spree/api/credit_cards/credit_card", credit_card: credit_card)
4
+ json.partial!("spree/api/credit_cards/credit_card", credit_card:)
5
5
  end
6
6
  json.partial! 'spree/api/shared/pagination', pagination: @credit_cards
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.images(@images) do |image|
4
- json.partial!("spree/api/images/image", image: image)
4
+ json.partial!("spree/api/images/image", image:)
5
5
  end
@@ -9,10 +9,10 @@ json.cache! [I18n.locale, line_item] do
9
9
  json.partial!("spree/api/variants/small", variant: line_item.variant)
10
10
  json.(line_item.variant, :product_id)
11
11
  json.images(line_item.variant.gallery.images) do |image|
12
- json.partial!("spree/api/images/image", image: image)
12
+ json.partial!("spree/api/images/image", image:)
13
13
  end
14
14
  end
15
15
  json.adjustments(line_item.adjustments) do |adjustment|
16
- json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment)
16
+ json.partial!("spree/api/adjustments/adjustment", adjustment:)
17
17
  end
18
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.array! @option_types do |option_type|
4
- json.partial!("spree/api/option_types/option_type", option_type: option_type)
4
+ json.partial!("spree/api/option_types/option_type", option_type:)
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.array! @option_values do |option_value|
4
- json.partial!("spree/api/option_values/option_value", option_value: option_value)
4
+ json.partial!("spree/api/option_values/option_value", option_value:)
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- json.partial!("spree/api/orders/order", order: order)
3
+ json.partial!("spree/api/orders/order", order:)
4
4
  json.payment_methods(order.available_payment_methods) do |payment_method|
5
5
  json.(payment_method, :id, :name, :partial_name)
6
6
  json.method_type payment_method.partial_name
@@ -20,7 +20,7 @@ json.ship_address do
20
20
  end
21
21
  end
22
22
  json.line_items(order.line_items) do |line_item|
23
- json.partial!("spree/api/line_items/line_item", line_item: line_item)
23
+ json.partial!("spree/api/line_items/line_item", line_item:)
24
24
  end
25
25
  json.payments(order.payments) do |payment|
26
26
  json.(payment, *payment_attributes)
@@ -36,7 +36,7 @@ json.payments(order.payments) do |payment|
36
36
  if payment_source
37
37
  json.partial!(
38
38
  "spree/api/payments/source_views/#{payment.payment_method.partial_name}",
39
- payment_source: payment_source
39
+ payment_source:
40
40
  )
41
41
  else
42
42
  json.nil!
@@ -44,14 +44,14 @@ json.payments(order.payments) do |payment|
44
44
  end
45
45
  end
46
46
  json.shipments(order.shipments) do |shipment|
47
- json.partial!("spree/api/shipments/small", shipment: shipment)
47
+ json.partial!("spree/api/shipments/small", shipment:)
48
48
  end
49
49
  json.adjustments(order.adjustments) do |adjustment|
50
- json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment)
50
+ json.partial!("spree/api/adjustments/adjustment", adjustment:)
51
51
  end
52
52
  json.permissions do
53
53
  json.can_update current_ability.can?(:update, order)
54
54
  end
55
55
  json.credit_cards(order.valid_credit_cards) do |credit_card|
56
- json.partial!("spree/api/credit_cards/credit_card", credit_card: credit_card)
56
+ json.partial!("spree/api/credit_cards/credit_card", credit_card:)
57
57
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.orders(@orders) do |order|
4
- json.partial!("spree/api/orders/order", order: order)
4
+ json.partial!("spree/api/orders/order", order:)
5
5
  end
6
6
  json.partial! 'spree/api/shared/pagination', pagination: @orders
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.orders(@orders) do |order|
4
- json.partial!("spree/api/orders/big", order: order)
4
+ json.partial!("spree/api/orders/big", order:)
5
5
  end
6
6
  json.partial! 'spree/api/shared/pagination', pagination: @orders
@@ -14,7 +14,7 @@ json.cache! [I18n.locale, @current_user_roles.include?('admin'), current_pricing
14
14
  json.partial!("spree/api/variants/small", variant: product.master)
15
15
  end
16
16
  json.variants(product.variants) do |variant|
17
- json.partial!("spree/api/variants/small", variant: variant)
17
+ json.partial!("spree/api/variants/small", variant:)
18
18
  end
19
19
  end
20
20
  unless @exclude_data[:option_types]
@@ -2,5 +2,5 @@
2
2
 
3
3
  json.partial! 'spree/api/shared/pagination', pagination: @products
4
4
  json.products(@products) do |product|
5
- json.partial!("spree/api/products/product", product: product)
5
+ json.partial!("spree/api/products/product", product:)
6
6
  end
@@ -2,14 +2,14 @@
2
2
 
3
3
  json.cache! [I18n.locale, shipment] do
4
4
  json.(shipment, *shipment_attributes)
5
- json.partial!("spree/api/shipments/small", shipment: shipment)
5
+ json.partial!("spree/api/shipments/small", shipment:)
6
6
  json.inventory_units(shipment.inventory_units) do |inventory_unit|
7
7
  json.(inventory_unit, *inventory_unit_attributes)
8
8
  json.variant do
9
9
  json.partial!("spree/api/variants/small", variant: inventory_unit.variant)
10
10
  json.(inventory_unit.variant, :product_id)
11
11
  json.images(inventory_unit.variant.gallery.images) do |image|
12
- json.partial!("spree/api/images/image", image: image)
12
+ json.partial!("spree/api/images/image", image:)
13
13
  end
14
14
  end
15
15
  json.line_item do
@@ -5,7 +5,7 @@ json.cache! [I18n.locale, shipment] do
5
5
  json.order_id(shipment.order.number)
6
6
  json.stock_location_name(shipment.stock_location.name)
7
7
  json.shipping_rates(shipment.shipping_rates) do |shipping_rate|
8
- json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate)
8
+ json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate:)
9
9
  end
10
10
  json.selected_shipping_rate do
11
11
  if shipment.selected_shipping_rate
@@ -29,6 +29,6 @@ json.cache! [I18n.locale, shipment] do
29
29
  json.states(manifest_item.states)
30
30
  end
31
31
  json.adjustments(shipment.adjustments) do |adjustment|
32
- json.partial!("spree/api/adjustments/adjustment", adjustment: adjustment)
32
+ json.partial!("spree/api/adjustments/adjustment", adjustment:)
33
33
  end
34
34
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  json.partial! 'spree/api/shared/pagination', pagination: @shipments
4
4
  json.shipments(@shipments) do |shipment|
5
- json.partial!("spree/api/shipments/big", shipment: shipment)
5
+ json.partial!("spree/api/shipments/big", shipment:)
6
6
  end
@@ -5,7 +5,7 @@ json.cache! [I18n.locale, @shipment] do
5
5
  json.order_id(@shipment.order.number)
6
6
  json.stock_location_name(@shipment.stock_location.name)
7
7
  json.shipping_rates(@shipment.shipping_rates) do |shipping_rate|
8
- json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate: shipping_rate)
8
+ json.partial!("spree/api/shipping_rates/shipping_rate", shipping_rate:)
9
9
  end
10
10
  json.selected_shipping_rate do
11
11
  if @shipment.selected_shipping_rate
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.stock_items(@stock_items) do |stock_item|
4
- json.partial!("spree/api/stock_items/stock_item", stock_item: stock_item)
4
+ json.partial!("spree/api/stock_items/stock_item", stock_item:)
5
5
  end
6
6
  json.partial! 'spree/api/shared/pagination', pagination: @stock_items
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.stock_locations(@stock_locations) do |stock_location|
4
- json.partial!("spree/api/stock_locations/stock_location", stock_location: stock_location)
4
+ json.partial!("spree/api/stock_locations/stock_location", stock_location:)
5
5
  end
6
6
  json.partial! 'spree/api/shared/pagination', pagination: @stock_locations
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.stock_movements(@stock_movements) do |stock_movement|
4
- json.partial!("spree/api/stock_movements/stock_movement", stock_movement: stock_movement)
4
+ json.partial!("spree/api/stock_movements/stock_movement", stock_movement:)
5
5
  end
6
6
  json.partial! 'spree/api/shared/pagination', pagination: @stock_movements
@@ -5,6 +5,6 @@ json.root do
5
5
  json.(taxonomy.root, *taxon_attributes)
6
6
  json.taxons(taxonomy.root.children) do |taxon|
7
7
  json.(taxon, *taxon_attributes)
8
- json.partial!("spree/api/taxons/taxons", taxon: taxon)
8
+ json.partial!("spree/api/taxons/taxons", taxon:)
9
9
  end
10
10
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  if params[:set] == "nested"
4
- json.partial!("spree/api/taxonomies/nested", taxonomy: taxonomy)
4
+ json.partial!("spree/api/taxonomies/nested", taxonomy:)
5
5
  else
6
6
  json.(taxonomy, *taxonomy_attributes)
7
7
  json.root do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.taxonomies(@taxonomies) do |taxonomy|
4
- json.partial!("spree/api/taxonomies/taxonomy", taxonomy: taxonomy)
4
+ json.partial!("spree/api/taxonomies/taxonomy", taxonomy:)
5
5
  end
6
6
  json.partial! 'spree/api/shared/pagination', pagination: @taxonomies
@@ -2,5 +2,5 @@
2
2
 
3
3
  json.taxons(taxon.children) do |taxon|
4
4
  json.(taxon, *taxon_attributes)
5
- json.partial!("spree/api/taxons/taxons", taxon: taxon)
5
+ json.partial!("spree/api/taxons/taxons", taxon:)
6
6
  end
@@ -4,6 +4,6 @@ json.partial! 'spree/api/shared/pagination', pagination: @taxons
4
4
  json.taxons(@taxons) do |taxon|
5
5
  json.(taxon, *taxon_attributes)
6
6
  unless params[:without_children]
7
- json.partial!("spree/api/taxons/taxons", taxon: taxon)
7
+ json.partial!("spree/api/taxons/taxons", taxon:)
8
8
  end
9
9
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.users(@users) do |user|
4
- json.partial!("spree/api/users/user", user: user)
4
+ json.partial!("spree/api/users/user", user:)
5
5
  end
6
6
  json.partial! 'spree/api/shared/pagination', pagination: @users
@@ -2,7 +2,7 @@
2
2
 
3
3
  json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant] do
4
4
  json.(variant, *variant_attributes)
5
- json.partial!("spree/api/variants/small", variant: variant)
5
+ json.partial!("spree/api/variants/small", variant:)
6
6
  json.variant_properties(variant.variant_properties) do |variant_property|
7
7
  json.(variant_property, *variant_property_attributes)
8
8
  end
@@ -16,6 +16,6 @@ json.cache! [I18n.locale, current_pricing_options, variant] do
16
16
  json.(option_value, *option_value_attributes)
17
17
  end
18
18
  json.images(variant.gallery.images) do |image|
19
- json.partial!("spree/api/images/image", image: image)
19
+ json.partial!("spree/api/images/image", image:)
20
20
  end
21
21
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  json.partial! 'spree/api/shared/pagination', pagination: @variants
4
4
  json.variants(@variants) do |variant|
5
- json.partial!("spree/api/variants/big", variant: variant)
5
+ json.partial!("spree/api/variants/big", variant:)
6
6
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  json.zones(@zones) do |zone|
4
- json.partial!("spree/api/zones/zone", zone: zone)
4
+ json.partial!("spree/api/zones/zone", zone:)
5
5
  end
6
6
  json.partial! 'spree/api/shared/pagination', pagination: @zones
@@ -72,8 +72,8 @@ module Spree
72
72
 
73
73
  preference :adjustment_attributes, :array, default: [
74
74
  :id, :source_type, :source_id, :adjustable_type, :adjustable_id,
75
- :amount, :label, :promotion_code_id,
76
- :finalized, :eligible, :created_at, :updated_at
75
+ :amount, :label,
76
+ :finalized, :created_at, :updated_at
77
77
  ]
78
78
 
79
79
  preference :inventory_unit_attributes, :array, default: [
@@ -112,10 +112,17 @@ module Spree
112
112
  :variant_id
113
113
  ]
114
114
 
115
- preference :promotion_attributes, :array, default: [
116
- :id, :name, :description, :expires_at, :starts_at, :type, :usage_limit,
117
- :advertise, :path
118
- ]
115
+ def promotion_attributes
116
+ Spree::Config.promotions.promotion_api_attributes
117
+ end
118
+ alias_method :preferred_promotion_attributes, :promotion_attributes
119
+
120
+ def promotion_attributes=(value)
121
+ Spree::Config.promotions.promotion_api_attributes = value
122
+ end
123
+ alias_method :preferred_promotion_attributes=, :promotion_attributes=
124
+ promotion_attributes_deprecation_message = "Spree::ApiConfiguration#promotion_attributes= is deprecated. Please use Spree::Config.promotions.promotion_api_attributes= instead."
125
+ deprecate "promotion_attributes=" => promotion_attributes_deprecation_message, deprecator: Spree.deprecator
119
126
 
120
127
  preference :store_attributes, :array, default: [
121
128
  :id, :name, :url, :meta_description, :meta_keywords, :seo_title,
@@ -6118,16 +6118,12 @@ components:
6118
6118
  type: string
6119
6119
  display_amount:
6120
6120
  type: string
6121
- eligible:
6122
- type: boolean
6123
6121
  finalized:
6124
6122
  type: boolean
6125
6123
  id:
6126
6124
  type: integer
6127
6125
  label:
6128
6126
  type: string
6129
- promotion_code_id:
6130
- type: integer
6131
6127
  source_id:
6132
6128
  type: integer
6133
6129
  source_type:
data/solidus_api.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  f.match(%r{^(spec|script)/})
21
21
  end
22
22
 
23
- s.required_ruby_version = '>= 3.0.0'
23
+ s.required_ruby_version = '>= 3.1.0'
24
24
  s.required_rubygems_version = '>= 1.8.23'
25
25
 
26
26
  s.add_dependency 'jbuilder', '~> 2.8'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.5
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-24 00:00:00.000000000 Z
11
+ date: 2024-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbuilder
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 4.3.5
61
+ version: 4.4.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 4.3.5
68
+ version: 4.4.0
69
69
  description: REST API for the Solidus e-commerce framework.
70
70
  email: contact@solidus.io
71
71
  executables: []
@@ -266,14 +266,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
266
266
  requirements:
267
267
  - - ">="
268
268
  - !ruby/object:Gem::Version
269
- version: 3.0.0
269
+ version: 3.1.0
270
270
  required_rubygems_version: !ruby/object:Gem::Requirement
271
271
  requirements:
272
272
  - - ">="
273
273
  - !ruby/object:Gem::Version
274
274
  version: 1.8.23
275
275
  requirements: []
276
- rubygems_version: 3.5.9
276
+ rubygems_version: 3.5.22
277
277
  signing_key:
278
278
  specification_version: 4
279
279
  summary: REST API for the Solidus e-commerce framework.