Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
API v3: Use flat request body parameters across all endpoints
Damian Legawiecde21137ff769
diff --git a/api/app/controllers/spree/api/v3/resource_controller.rb b/api/app/controllers/spree/api/v3/resource_controller.rbindex 507867c7c5..308c4cfd9c 100644--- a/api/app/controllers/spree/api/v3/resource_controller.rb+++ b/api/app/controllers/spree/api/v3/resource_controller.rb@@ -184,9 +184,25 @@ module Spreeraise NotImplementedError, 'Subclass must implement serializer_class'end- # Override in subclass to permit parameters+ # Permit flat parameters based on model class+ # Automatically infers attribute list from Spree::PermittedAttributes+ # e.g., ProductsController -> Spree::PermittedAttributes.product_attributes+ #+ # Override in subclass for custom parameter handlingdef permitted_params- raise NotImplementedError, 'Subclass must implement permitted_params'+ params.permit(permitted_attributes)+ end++ # Returns the permitted attributes list for the model+ # Override in subclass for custom attributes+ def permitted_attributes+ Spree::PermittedAttributes.public_send(permitted_attributes_key)+ end++ # Infers the PermittedAttributes key from model class+ # e.g., Spree::Product -> :product_attributes+ def permitted_attributes_key+ :"#{model_class.model_name.element}_attributes"endendenddiff --git a/api/app/controllers/spree/api/v3/store/auth_controller.rb b/api/app/controllers/spree/api/v3/store/auth_controller.rbindex 746d3dd812..70d3a3f492 100644--- a/api/app/controllers/spree/api/v3/store/auth_controller.rb+++ b/api/app/controllers/spree/api/v3/store/auth_controller.rb@@ -129,7 +129,7 @@ module Spreeenddef registration_params- params.require(:user).permit(:email, :password, :password_confirmation, :first_name, :last_name)+ params.permit(:email, :password, :password_confirmation, :first_name, :last_name)enddef user_serializerdiff --git a/api/app/controllers/spree/api/v3/store/customer/account_controller.rb b/api/app/controllers/spree/api/v3/store/customer/account_controller.rbindex 713ae4c567..ea56cf6f59 100644--- a/api/app/controllers/spree/api/v3/store/customer/account_controller.rb+++ b/api/app/controllers/spree/api/v3/store/customer/account_controller.rb@@ -27,7 +27,7 @@ module Spreeenddef permitted_params- params.require(:user).permit(Spree::PermittedAttributes.user_attributes)+ params.permit(Spree::PermittedAttributes.user_attributes)endendenddiff --git a/api/app/controllers/spree/api/v3/store/customer/addresses_controller.rb b/api/app/controllers/spree/api/v3/store/customer/addresses_controller.rbindex 6a1e14f670..3a7c783ba1 100644--- a/api/app/controllers/spree/api/v3/store/customer/addresses_controller.rb+++ b/api/app/controllers/spree/api/v3/store/customer/addresses_controller.rb@@ -53,7 +53,7 @@ module Spreeenddef permitted_params- params.require(:address).permit(+ params.permit(:firstname, :lastname, :address1, :address2, :city,:zipcode, :phone, :company, :country_iso, :state_abbr, :state_name)diff --git a/api/app/controllers/spree/api/v3/store/customer/payment_sources_controller.rb b/api/app/controllers/spree/api/v3/store/customer/payment_sources_controller.rbdeleted file mode 100644index 1eede5520a..0000000000--- a/api/app/controllers/spree/api/v3/store/customer/payment_sources_controller.rb+++ /dev/null@@ -1,31 +0,0 @@-module Spree- module Api- module V3- module Store- module Customer- class PaymentSourcesController < ResourceController- prepend_before_action :require_authentication!-- protected-- def set_parent- @parent = current_user- end-- def parent_association- :wallet_payment_sources- end-- def model_class- Spree::WalletPaymentSource- end-- def serializer_class- Spree.api.wallet_payment_source_serializer- end- end- end- end- end- end-enddiff --git a/api/app/controllers/spree/api/v3/store/orders/coupon_codes_controller.rb b/api/app/controllers/spree/api/v3/store/orders/coupon_codes_controller.rbindex 8928be90bc..b82dab703a 100644--- a/api/app/controllers/spree/api/v3/store/orders/coupon_codes_controller.rb+++ b/api/app/controllers/spree/api/v3/store/orders/coupon_codes_controller.rb@@ -12,7 +12,7 @@ module Spree# POST /api/v3/store/orders/:order_id/coupon_codes# Apply a coupon code to the orderdef create- @parent.coupon_code = permitted_params[:coupon_code]+ @parent.coupon_code = permitted_params[:code]coupon_handler.apply@@ -49,7 +49,7 @@ module Spreeenddef permitted_params- params.require(:coupon_code).permit(:coupon_code)+ params.permit(:code)enddef model_classdiff --git a/api/app/controllers/spree/api/v3/store/orders/line_items_controller.rb b/api/app/controllers/spree/api/v3/store/orders/line_items_controller.rbindex feff807b30..1ac1ed523d 100644--- a/api/app/controllers/spree/api/v3/store/orders/line_items_controller.rb+++ b/api/app/controllers/spree/api/v3/store/orders/line_items_controller.rb@@ -78,7 +78,7 @@ module Spreeenddef permitted_params- params.require(:line_item).permit(Spree::PermittedAttributes.line_item_attributes + [{ options: {} }])+ params.permit(Spree::PermittedAttributes.line_item_attributes + [{ options: {} }])endendenddiff --git a/api/app/controllers/spree/api/v3/store/orders/shipments_controller.rb b/api/app/controllers/spree/api/v3/store/orders/shipments_controller.rbindex a19633f752..15d7a8def3 100644--- a/api/app/controllers/spree/api/v3/store/orders/shipments_controller.rb+++ b/api/app/controllers/spree/api/v3/store/orders/shipments_controller.rb@@ -36,7 +36,7 @@ module Spreeenddef permitted_params- params.require(:shipment).permit(:selected_shipping_rate_id)+ params.permit(:selected_shipping_rate_id)endprivatediff --git a/api/app/controllers/spree/api/v3/store/orders_controller.rb b/api/app/controllers/spree/api/v3/store/orders_controller.rbindex c0e26481bc..162b56c355 100644--- a/api/app/controllers/spree/api/v3/store/orders_controller.rb+++ b/api/app/controllers/spree/api/v3/store/orders_controller.rb@@ -24,19 +24,25 @@ module Spreeend# PATCH /api/v3/store/orders/:id+ #+ # Accepts flat parameters:+ # {+ # "email": "[email protected]",+ # "currency": "EUR",+ # "ship_address": { "firstname": "John", "country_iso": "US", ... },+ # "bill_address": { "firstname": "John", "country_iso": "US", ... }+ # }+ #def update- result = Spree.checkout_update_service.call(+ result = Spree::Api::V3::Orders::Update.call(order: @order,- params: params,- # defined in https://github.com/spree/spree/blob/main/core/lib/spree/core/controller_helpers/strong_parameters.rb#L19- permitted_attributes: permitted_checkout_attributes,- request_env: request.headers.env+ params: order_params)if result.success?render json: serialize_resource(@order.reload)else- render_errors(@order.errors)+ render_service_error(result.error, code: ERROR_CODES[:validation_error])endend@@ -107,8 +113,24 @@ module SpreeSpree.api.order_serializerend- def permitted_params- params.require(:order).permit(Spree::PermittedAttributes.checkout_attributes)+ def order_params+ params.permit(+ :email,+ :currency,+ :special_instructions,+ :ship_address_id,+ :bill_address_id,+ ship_address: address_params,+ bill_address: address_params+ )+ end++ def address_params+ [+ :id, :firstname, :lastname, :address1, :address2,+ :city, :zipcode, :phone, :company,+ :country_iso, :state_abbr, :state_name+ ]endendenddiff --git a/api/app/controllers/spree/api/v3/store/wishlist_items_controller.rb b/api/app/controllers/spree/api/v3/store/wishlist_items_controller.rbindex c86e1749cd..06fbe06540 100644--- a/api/app/controllers/spree/api/v3/store/wishlist_items_controller.rb+++ b/api/app/controllers/spree/api/v3/store/wishlist_items_controller.rb@@ -24,7 +24,7 @@ module Spreeenddef permitted_params- params.require(:wished_item).permit(Spree::PermittedAttributes.wished_item_attributes)+ params.permit(Spree::PermittedAttributes.wished_item_attributes)endendenddiff --git a/api/app/controllers/spree/api/v3/store/wishlists_controller.rb b/api/app/controllers/spree/api/v3/store/wishlists_controller.rbindex bd6776b6de..3d03eefc11 100644--- a/api/app/controllers/spree/api/v3/store/wishlists_controller.rb+++ b/api/app/controllers/spree/api/v3/store/wishlists_controller.rb@@ -32,7 +32,7 @@ module Spreeenddef permitted_params- params.require(:wishlist).permit(Spree::PermittedAttributes.wishlist_attributes)+ params.permit(Spree::PermittedAttributes.wishlist_attributes)endendenddiff --git a/api/app/services/spree/api/v3/orders/update.rb b/api/app/services/spree/api/v3/orders/update.rbnew file mode 100644index 0000000000..38b03526bc--- /dev/null+++ b/api/app/services/spree/api/v3/orders/update.rb@@ -0,0 +1,209 @@+module Spree+ module Api+ module V3+ module Orders+ # Clean API v3 order update service with modern conventions:+ # - Flat parameter structure (no wrapping in "order" key)+ # - snake_case field names without "_attributes" suffix+ # - Automatic state management based on what's being updated+ #+ # @example Update shipping address+ # Spree::Api::V3::Orders::Update.call(+ # order: order,+ # params: {+ # email: "[email protected]",+ # ship_address: {+ # firstname: "John",+ # lastname: "Doe",+ # address1: "123 Main St",+ # city: "New York",+ # zipcode: "10001",+ # country_iso: "US",+ # state_abbr: "NY"+ # }+ # }+ # )+ #+ # @example Change currency+ # Spree::Api::V3::Orders::Update.call(+ # order: order,+ # params: { currency: "EUR" }+ # )+ class Update+ prepend Spree::ServiceModule::Base+ include Spree::Addresses::Helper++ PERMITTED_ORDER_PARAMS = %i[+ special_instructions+ currency+ bill_address_id+ ship_address_id+ ].freeze++ PERMITTED_ADDRESS_PARAMS = %i[+ id+ firstname+ lastname+ address1+ address2+ city+ zipcode+ phone+ company+ country_iso+ state_abbr+ state_name+ ].freeze++ def call(order:, params:)+ @order = order+ @params = params.to_h.deep_symbolize_keys++ return failure(order, validation_error) if validation_error.present?++ ApplicationRecord.transaction do+ update_currency if @params[:currency].present?+ update_email if @params[:email].present?+ update_special_instructions if @params[:special_instructions].present?+ update_ship_address if @params[:ship_address].present?+ update_bill_address if @params[:bill_address].present?+ update_address_ids++ order.save!+ end++ success(order.reload)+ rescue ActiveRecord::RecordInvalid => e+ failure(order, e.record.errors.full_messages.to_sentence)+ rescue StandardError => e+ failure(order, e.message)+ end++ private++ attr_reader :order, :params++ def validation_error+ @validation_error ||= begin+ error = validate_currency+ error ||= validate_address_ownership(:ship_address)+ error ||= validate_address_ownership(:bill_address)+ error+ end+ end++ def validate_currency+ new_currency = params[:currency]+ return nil unless new_currency.present?++ supported_currencies = order.store.supported_currencies_list.map(&:iso_code)+ return nil if supported_currencies.include?(new_currency.upcase)++ Spree.t(:currency_not_supported, currency: new_currency)+ end++ def validate_address_ownership(address_type)+ address_params = params[address_type]+ return nil unless address_params.is_a?(Hash)++ address_id = address_params[:id]+ return nil unless address_id.present?++ address = Spree::Address.find_by_prefix_id(address_id)+ return nil unless address++ # Allow if address has no user (guest address) or belongs to the order's user+ return nil if address.user_id.nil?+ return nil if order.user_id.present? && address.user_id == order.user_id++ Spree.t(:address_not_owned_by_user)+ end++ def update_currency+ new_currency = params[:currency].upcase+ return if order.currency == new_currency++ order.currency = new_currency+ order.homogenize_line_item_currencies+ end++ def update_email+ order.email = params[:email]+ end++ def update_special_instructions+ order.special_instructions = params[:special_instructions]+ end++ def update_ship_address+ address_params = normalize_address_params(params[:ship_address])++ if address_params[:id].present?+ # Using existing address - find by prefix_id+ existing = Spree::Address.find_by_prefix_id!(address_params[:id])+ order.ship_address_id = existing.id+ else+ # Creating/updating address+ revert_to_address_state if order.has_checkout_step?('address')+ order.ship_address = build_or_update_address(order.ship_address, address_params)+ end+ end++ def update_bill_address+ address_params = normalize_address_params(params[:bill_address])++ if address_params[:id].present?+ # Using existing address - find by prefix_id+ existing = Spree::Address.find_by_prefix_id!(address_params[:id])+ order.bill_address_id = existing.id+ else+ # Creating/updating address+ revert_to_address_state if order.has_checkout_step?('address')+ order.bill_address = build_or_update_address(order.bill_address, address_params)+ end+ end++ def update_address_ids+ if params[:ship_address_id].present?+ existing = Spree::Address.find_by_prefix_id!(params[:ship_address_id])+ # Use bracket notation to bypass Order::AddressBook custom setter+ # which requires address.user_id == order.user_id+ order[:ship_address_id] = existing.id+ end+ if params[:bill_address_id].present?+ existing = Spree::Address.find_by_prefix_id!(params[:bill_address_id])+ # Use bracket notation to bypass Order::AddressBook custom setter+ order[:bill_address_id] = existing.id+ end+ end++ def normalize_address_params(address_params)+ return {} unless address_params.is_a?(Hash)++ normalized = address_params.slice(*PERMITTED_ADDRESS_PARAMS)+ fill_country_and_state_ids(normalized)+ normalized+ end++ def build_or_update_address(existing_address, address_params)+ if existing_address.present? && existing_address.editable?+ existing_address.assign_attributes(address_params.except(:id))+ existing_address+ else+ Spree::Address.new(address_params.except(:id).merge(user: order.user))+ end+ end++ # Revert order state to 'address' when address changes+ # This ensures shipments are recreated when transitioning back to delivery+ def revert_to_address_state+ return if order.state == 'cart' || order.state == 'address'++ order.state = 'address'+ end+ end+ end+ end+ end+enddiff --git a/api/config/routes.rb b/api/config/routes.rbindex d0c68aeac1..ce9abd5b6f 100644--- a/api/config/routes.rb+++ b/api/config/routes.rb@@ -53,7 +53,6 @@ Spree::Core::Engine.add_routes dopatch '/', to: 'account#update'resources :addresses, only: [:index, :show, :create, :update, :destroy]resources :credit_cards, only: [:index, :show, :destroy]- resources :payment_sources, only: [:index, :show, :destroy]end# Wishlistsdiff --git a/api/spec/controllers/spree/api/v3/store/addresses_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/addresses_controller_spec.rbdeleted file mode 100644index 76b1f13a25..0000000000--- a/api/spec/controllers/spree/api/v3/store/addresses_controller_spec.rb+++ /dev/null@@ -1,277 +0,0 @@-require 'spec_helper'--RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do- render_views-- include_context 'API v3 Store'-- let(:country) { create(:country, states_required: true) }- let(:state) { create(:state, country: country) }- let!(:address) { create(:address, user: user, country: country, state: state) }-- before do- request.headers['X-Spree-Api-Key'] = api_key.token- request.headers['Authorization'] = "Bearer #{jwt_token}"- end-- describe 'GET #index' do- it 'returns user addresses' do- get :index-- expect(response).to have_http_status(:ok)- expect(json_response['data']).to be_present- end-- it 'returns pagination metadata' do- get :index-- expect(json_response['meta']).to include('page', 'count', 'pages')- end-- context 'without authentication' do- before { request.headers['Authorization'] = nil }-- it 'returns unauthorized' do- get :index-- expect(response).to have_http_status(:unauthorized)- expect(json_response['error']['code']).to eq('authentication_required')- expect(json_response['error']['message']).to be_present- end- end- end-- describe 'GET #show' do- it 'returns the address' do- get :show, params: { id: address.prefix_id }-- expect(response).to have_http_status(:ok)- expect(json_response['id']).to eq(address.prefix_id)- expect(json_response['firstname']).to eq(address.firstname)- expect(json_response['lastname']).to eq(address.lastname)- end-- context 'error handling' do- it 'returns not found for non-existent address' do- get :show, params: { id: 0 }-- expect(response).to have_http_status(:not_found)- expect(json_response['error']['code']).to eq('record_not_found')- expect(json_response['error']['message']).to be_present- end-- it 'returns not found for other users address' do- other_user = create(:user)- other_address = create(:address, user: other_user)-- get :show, params: { id: other_address.prefix_id }-- expect(response).to have_http_status(:not_found)- expect(json_response['error']['code']).to eq('record_not_found')- end- end- end-- describe 'POST #create' do- let(:valid_params) do- {- address: {- firstname: 'John',- lastname: 'Doe',- address1: '123 Main St',- city: 'New York',- zipcode: '10001',- phone: '555-1234',- country_iso: country.iso,- state_abbr: state.abbr- }- }- end-- it 'creates a new address' do- expect {- post :create, params: valid_params- }.to change(Spree::Address, :count).by(1)-- expect(response).to have_http_status(:created)- expect(json_response['firstname']).to eq('John')- expect(json_response['lastname']).to eq('Doe')- end-- it 'associates address with current user' do- post :create, params: valid_params-- expect(Spree::Address.last.user_id).to eq(user.id)- end-- context 'with state_abbr for country with states required' do- let(:address_params) do- {- address: {- firstname: 'Jane',- lastname: 'Smith',- address1: '456 Oak Ave',- city: 'Los Angeles',- zipcode: '90001',- phone: '555-5678',- country_iso: country.iso,- state_abbr: state.abbr- }- }- end-- it 'creates address using country_iso and state_abbr' do- expect {- post :create, params: address_params- }.to change(Spree::Address, :count).by(1)-- expect(response).to have_http_status(:created)- expect(json_response['firstname']).to eq('Jane')- expect(json_response['country_iso']).to eq(country.iso)- expect(json_response['state_abbr']).to eq(state.abbr)- expect(json_response['state_name']).to eq(state.name)- end- end-- context 'with state_name for country without states required' do- let(:country_without_states) { create(:country, states_required: false) }- let(:state_name_params) do- {- address: {- firstname: 'Hans',- lastname: 'Mueller',- address1: '789 Berlin Str',- city: 'Berlin',- zipcode: '10115',- phone: '555-9999',- country_iso: country_without_states.iso,- state_name: 'Berlin'- }- }- end-- it 'creates address with state_name' do- expect {- post :create, params: state_name_params- }.to change(Spree::Address, :count).by(1)-- expect(response).to have_http_status(:created)- expect(json_response['firstname']).to eq('Hans')- expect(json_response['state_abbr']).to be_nil- expect(json_response['state_name']).to eq('Berlin')- end- end-- context 'validation errors' do- it 'returns errors for missing required fields' do- post :create, params: { address: { firstname: 'John' } }-- expect(response).to have_http_status(:unprocessable_entity)- expect(json_response['error']['code']).to eq('validation_error')- expect(json_response['error']['message']).to be_present- end-- it 'returns errors for blank firstname' do- post :create, params: { address: valid_params[:address].merge(firstname: '') }-- expect(response).to have_http_status(:unprocessable_entity)- expect(json_response['error']['code']).to eq('validation_error')- expect(json_response['error']['details']['firstname']).to be_present- end-- it 'returns errors for invalid country' do- post :create, params: { address: valid_params[:address].merge(country_iso: 'XX') }-- expect(response).to have_http_status(:unprocessable_entity)- expect(json_response['error']['code']).to eq('validation_error')- expect(json_response['error']['details']['country']).to be_present- end- end-- context 'without authentication' do- before { request.headers['Authorization'] = nil }-- it 'returns unauthorized' do- post :create, params: valid_params-- expect(response).to have_http_status(:unauthorized)- expect(json_response['error']['code']).to eq('authentication_required')- end- end- end-- describe 'PATCH #update' do- it 'updates the address' do- patch :update, params: { id: address.prefix_id, address: { address1: 'Updated Street' } }-- expect(response).to have_http_status(:ok)- expect(address.reload.address1).to eq('Updated Street')- end-- it 'updates multiple fields' do- patch :update, params: {- id: address.prefix_id,- address: { firstname: 'Jane', lastname: 'Smith', city: 'Boston' }- }-- expect(response).to have_http_status(:ok)- address.reload- expect(address.firstname).to eq('Jane')- expect(address.lastname).to eq('Smith')- expect(address.city).to eq('Boston')- end-- context 'validation errors' do- it 'returns errors for invalid update' do- patch :update, params: { id: address.prefix_id, address: { firstname: '' } }-- expect(response).to have_http_status(:unprocessable_entity)- expect(json_response['error']['code']).to eq('validation_error')- expect(json_response['error']['details']['firstname']).to be_present- end- end-- context 'error handling' do- it 'returns not found for other users address' do- other_user = create(:user)- other_address = create(:address, user: other_user)-- patch :update, params: { id: other_address.prefix_id, address: { address1: 'Hack Street' } }-- expect(response).to have_http_status(:not_found)- expect(json_response['error']['code']).to eq('record_not_found')- expect(json_response['error']['message']).to be_present- end- end- end-- describe 'DELETE #destroy' do- it 'deletes the address' do- expect {- delete :destroy, params: { id: address.prefix_id }- }.to change(Spree::Address, :count).by(-1)-- expect(response).to have_http_status(:no_content)- end-- context 'error handling' do- it 'returns not found for non-existent address' do- delete :destroy, params: { id: 0 }-- expect(response).to have_http_status(:not_found)- expect(json_response['error']['code']).to eq('record_not_found')- expect(json_response['error']['message']).to be_present- end-- it 'returns not found for other users address' do- other_user = create(:user)- other_address = create(:address, user: other_user)-- delete :destroy, params: { id: other_address.prefix_id }-- expect(response).to have_http_status(:not_found)- expect(json_response['error']['code']).to eq('record_not_found')- end- end- end-enddiff --git a/api/spec/controllers/spree/api/v3/store/auth_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/auth_controller_spec.rbindex 835388fccb..0b1eb71326 100644--- a/api/spec/controllers/spree/api/v3/store/auth_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/auth_controller_spec.rb@@ -68,11 +68,9 @@ RSpec.describe Spree::Api::V3::Store::AuthController, type: :controller dodescribe 'POST #register' dolet(:valid_params) do{- user: {- email: '[email protected]',- password: 'password123',- password_confirmation: 'password123'- }+ email: '[email protected]',+ password: 'password123',+ password_confirmation: 'password123'}end@@ -99,7 +97,7 @@ RSpec.describe Spree::Api::V3::Store::AuthController, type: :controller docontext 'validation errors' doit 'returns validation error for blank email' do- post :register, params: { user: { email: '', password: 'password123', password_confirmation: 'password123' } }+ post :register, params: { email: '', password: 'password123', password_confirmation: 'password123' }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -108,7 +106,7 @@ RSpec.describe Spree::Api::V3::Store::AuthController, type: :controller doit 'returns validation error for duplicate email' doexisting_user = create(:user)- post :register, params: { user: { email: existing_user.email, password: 'password123', password_confirmation: 'password123' } }+ post :register, params: { email: existing_user.email, password: 'password123', password_confirmation: 'password123' }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')diff --git a/api/spec/controllers/spree/api/v3/store/customer/account_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/customer/account_controller_spec.rbindex 261ef54938..776e46a0cd 100644--- a/api/spec/controllers/spree/api/v3/store/customer/account_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/customer/account_controller_spec.rb@@ -63,14 +63,14 @@ RSpec.describe Spree::Api::V3::Store::Customer::AccountController, type: :controdescribe 'PATCH #update' doit 'updates the current user first name' do- patch :update, params: { user: { first_name: 'Updated' } }+ patch :update, params: { first_name: 'Updated' }expect(response).to have_http_status(:ok)expect(user.reload.first_name).to eq('Updated')endit 'updates multiple fields' do- patch :update, params: { user: { first_name: 'John', last_name: 'Doe' } }+ patch :update, params: { first_name: 'John', last_name: 'Doe' }expect(response).to have_http_status(:ok)user.reload@@ -79,14 +79,14 @@ RSpec.describe Spree::Api::V3::Store::Customer::AccountController, type: :controendit 'returns updated user data' do- patch :update, params: { user: { first_name: 'Updated' } }+ patch :update, params: { first_name: 'Updated' }expect(json_response['first_name']).to eq('Updated')endcontext 'validation errors' doit 'returns errors for blank email' do- patch :update, params: { user: { email: '' } }+ patch :update, params: { email: '' }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -95,7 +95,7 @@ RSpec.describe Spree::Api::V3::Store::Customer::AccountController, type: :controit 'returns errors for duplicate email' doother_user = create(:user)- patch :update, params: { user: { email: other_user.email } }+ patch :update, params: { email: other_user.email }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -107,7 +107,7 @@ RSpec.describe Spree::Api::V3::Store::Customer::AccountController, type: :controbefore { request.headers['Authorization'] = nil }it 'returns unauthorized' do- patch :update, params: { user: { first_name: 'Updated' } }+ patch :update, params: { first_name: 'Updated' }expect(response).to have_http_status(:unauthorized)expect(json_response['error']['code']).to eq('authentication_required')diff --git a/api/spec/controllers/spree/api/v3/store/customer/addresses_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/customer/addresses_controller_spec.rbindex a65253d5bd..21d71f619c 100644--- a/api/spec/controllers/spree/api/v3/store/customer/addresses_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/customer/addresses_controller_spec.rb@@ -103,14 +103,14 @@ RSpec.describe Spree::Api::V3::Store::Customer::AddressesController, type: :contit 'creates a new address' doexpect {- post :create, params: { address: address_params }+ post :create, params: address_params}.to change { user.addresses.count }.by(1)expect(response).to have_http_status(:created)endit 'returns the created address' do- post :create, params: { address: address_params }+ post :create, params: address_paramsexpect(json_response['firstname']).to eq('John')expect(json_response['lastname']).to eq('Doe')@@ -119,7 +119,7 @@ RSpec.describe Spree::Api::V3::Store::Customer::AddressesController, type: :contcontext 'with invalid params' doit 'returns validation errors for missing firstname' do- post :create, params: { address: address_params.except(:firstname) }+ post :create, params: address_params.except(:firstname)expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -130,7 +130,7 @@ RSpec.describe Spree::Api::V3::Store::Customer::AddressesController, type: :contbefore { request.headers['Authorization'] = nil }it 'returns unauthorized' do- post :create, params: { address: address_params }+ post :create, params: address_paramsexpect(response).to have_http_status(:unauthorized)end@@ -139,14 +139,14 @@ RSpec.describe Spree::Api::V3::Store::Customer::AddressesController, type: :contdescribe 'PATCH #update' doit 'updates the address' do- patch :update, params: { id: address.prefix_id, address: { firstname: 'Updated' } }+ patch :update, params: { id: address.prefix_id, firstname: 'Updated' }expect(response).to have_http_status(:ok)expect(address.reload.firstname).to eq('Updated')endit 'returns the updated address' do- patch :update, params: { id: address.prefix_id, address: { firstname: 'Updated' } }+ patch :update, params: { id: address.prefix_id, firstname: 'Updated' }expect(json_response['firstname']).to eq('Updated')end@@ -156,7 +156,7 @@ RSpec.describe Spree::Api::V3::Store::Customer::AddressesController, type: :contlet(:other_address) { create(:address, user: other_user) }it 'returns not found' do- patch :update, params: { id: other_address.prefix_id, address: { firstname: 'Hacker' } }+ patch :update, params: { id: other_address.prefix_id, firstname: 'Hacker' }expect(response).to have_http_status(:not_found)expect(other_address.reload.firstname).not_to eq('Hacker')@@ -167,7 +167,7 @@ RSpec.describe Spree::Api::V3::Store::Customer::AddressesController, type: :contbefore { request.headers['Authorization'] = nil }it 'returns unauthorized' do- patch :update, params: { id: address.prefix_id, address: { firstname: 'Updated' } }+ patch :update, params: { id: address.prefix_id, firstname: 'Updated' }expect(response).to have_http_status(:unauthorized)end@@ -184,8 +184,8 @@ RSpec.describe Spree::Api::V3::Store::Customer::AddressesController, type: :contendcontext 'when address belongs to another user' do- let(:other_user) { create(:user) }- let(:other_address) { create(:address, user: other_user) }+ let!(:other_user) { create(:user) }+ let!(:other_address) { create(:address, user: other_user) }it 'returns not found' doexpect {diff --git a/api/spec/controllers/spree/api/v3/store/customer/credit_cards_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/customer/credit_cards_controller_spec.rbindex bdf901cdc2..8f602dd54e 100644--- a/api/spec/controllers/spree/api/v3/store/customer/credit_cards_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/customer/credit_cards_controller_spec.rb@@ -89,8 +89,8 @@ RSpec.describe Spree::Api::V3::Store::Customer::CreditCardsController, type: :coendcontext 'when credit card belongs to another user' do- let(:other_user) { create(:user) }- let(:other_card) { create(:credit_card, user: other_user) }+ let!(:other_user) { create(:user) }+ let!(:other_card) { create(:credit_card, user: other_user) }it 'returns not found' doexpect {diff --git a/api/spec/controllers/spree/api/v3/store/customer/payment_sources_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/customer/payment_sources_controller_spec.rbdeleted file mode 100644index 63e64cbf65..0000000000--- a/api/spec/controllers/spree/api/v3/store/customer/payment_sources_controller_spec.rb+++ /dev/null@@ -1,118 +0,0 @@-require 'spec_helper'--RSpec.describe Spree::Api::V3::Store::Customer::PaymentSourcesController, type: :controller do- render_views-- include_context 'API v3 Store'-- let(:credit_card) { create(:credit_card, user: user) }- let!(:payment_source) { create(:wallet_payment_source, user: user, payment_source: credit_card) }-- before do- request.headers['X-Spree-Api-Key'] = api_key.token- request.headers['Authorization'] = "Bearer #{jwt_token}"- end-- describe 'GET #index' do- it 'returns the user wallet payment sources' do- get :index-- expect(response).to have_http_status(:ok)- expect(json_response['data'].length).to eq(user.wallet_payment_sources.count)- end-- it 'returns payment source attributes' do- get :index-- source_data = json_response['data'].first- expect(source_data).to include('id', 'default')- end-- it 'only returns payment sources belonging to the current user' do- other_user = create(:user)- other_card = create(:credit_card, user: other_user)- other_source = create(:wallet_payment_source, user: other_user, payment_source: other_card)-- get :index-- ids = json_response['data'].map { |s| s['id'] }- expect(ids).to include(payment_source.prefix_id)- expect(ids).not_to include(other_source.prefix_id)- end-- context 'without authentication' do- before { request.headers['Authorization'] = nil }-- it 'returns unauthorized' do- get :index-- expect(response).to have_http_status(:unauthorized)- end- end- end-- describe 'GET #show' do- it 'returns the payment source' do- get :show, params: { id: payment_source.prefix_id }-- expect(response).to have_http_status(:ok)- expect(json_response['id']).to eq(payment_source.prefix_id)- end-- context 'when payment source belongs to another user' do- let(:other_user) { create(:user) }- let(:other_card) { create(:credit_card, user: other_user) }- let(:other_source) { create(:wallet_payment_source, user: other_user, payment_source: other_card) }-- it 'returns not found' do- get :show, params: { id: other_source.prefix_id }-- expect(response).to have_http_status(:not_found)- end- end-- context 'without authentication' do- before { request.headers['Authorization'] = nil }-- it 'returns unauthorized' do- get :show, params: { id: payment_source.prefix_id }-- expect(response).to have_http_status(:unauthorized)- end- end- end-- describe 'DELETE #destroy' do- it 'deletes the payment source' do- expect {- delete :destroy, params: { id: payment_source.prefix_id }- }.to change { user.wallet_payment_sources.count }.by(-1)-- expect(response).to have_http_status(:no_content)- end-- context 'when payment source belongs to another user' do- let(:other_user) { create(:user) }- let(:other_card) { create(:credit_card, user: other_user) }- let(:other_source) { create(:wallet_payment_source, user: other_user, payment_source: other_card) }-- it 'returns not found' do- expect {- delete :destroy, params: { id: other_source.prefix_id }- }.not_to change { Spree::WalletPaymentSource.count }-- expect(response).to have_http_status(:not_found)- end- end-- context 'without authentication' do- before { request.headers['Authorization'] = nil }-- it 'returns unauthorized' do- delete :destroy, params: { id: payment_source.prefix_id }-- expect(response).to have_http_status(:unauthorized)- end- end- end-enddiff --git a/api/spec/controllers/spree/api/v3/store/customers_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/customers_controller_spec.rbdeleted file mode 100644index 8ea8f283f2..0000000000--- a/api/spec/controllers/spree/api/v3/store/customers_controller_spec.rb+++ /dev/null@@ -1,120 +0,0 @@-require 'spec_helper'--RSpec.describe Spree::Api::V3::Store::CustomersController, type: :controller do- render_views-- include_context 'API v3 Store'-- before do- request.headers['X-Spree-Api-Key'] = api_key.token- request.headers['Authorization'] = "Bearer #{jwt_token}"- end-- describe 'GET #show' do- it 'returns the current user' do- get :show, params: { id: 'me' }-- expect(response).to have_http_status(:ok)- expect(json_response['id']).to eq(user.prefix_id)- expect(json_response['email']).to eq(user.email)- end-- it 'returns user attributes' do- get :show, params: { id: 'me' }-- expect(json_response).to include('id', 'email', 'first_name', 'last_name')- end-- context 'without authentication' do- before { request.headers['Authorization'] = nil }-- it 'returns unauthorized' do- get :show, params: { id: 'me' }-- expect(response).to have_http_status(:unauthorized)- expect(json_response['error']['code']).to eq('authentication_required')- expect(json_response['error']['message']).to be_present- end- end-- context 'with invalid token' do- before { request.headers['Authorization'] = 'Bearer invalid' }-- it 'returns unauthorized' do- get :show, params: { id: 'me' }-- expect(response).to have_http_status(:unauthorized)- expect(json_response['error']['code']).to eq('authentication_required')- expect(json_response['error']['message']).to be_present- end- end-- context 'with expired token' do- let(:expired_token) { Spree::Api::V3::TestingSupport.generate_jwt(user, expiration: -1.hour.to_i) }-- before { request.headers['Authorization'] = "Bearer #{expired_token}" }-- it 'returns unauthorized' do- get :show, params: { id: 'me' }-- expect(response).to have_http_status(:unauthorized)- expect(json_response['error']['code']).to eq('authentication_required')- expect(json_response['error']['message']).to be_present- end- end- end-- describe 'PATCH #update' do- it 'updates the current user first name' do- patch :update, params: { id: 'me', user: { first_name: 'Updated' } }-- expect(response).to have_http_status(:ok)- expect(user.reload.first_name).to eq('Updated')- end-- it 'updates multiple fields' do- patch :update, params: { id: 'me', user: { first_name: 'John', last_name: 'Doe' } }-- expect(response).to have_http_status(:ok)- user.reload- expect(user.first_name).to eq('John')- expect(user.last_name).to eq('Doe')- end-- it 'returns updated user data' do- patch :update, params: { id: 'me', user: { first_name: 'Updated' } }-- expect(json_response['first_name']).to eq('Updated')- end-- context 'validation errors' do- it 'returns errors for blank email' do- patch :update, params: { id: 'me', user: { email: '' } }-- expect(response).to have_http_status(:unprocessable_entity)- expect(json_response['error']['code']).to eq('validation_error')- expect(json_response['error']['details']['email']).to be_present- end-- it 'returns errors for duplicate email' do- other_user = create(:user)- patch :update, params: { id: 'me', user: { email: other_user.email } }-- expect(response).to have_http_status(:unprocessable_entity)- expect(json_response['error']['code']).to eq('validation_error')- expect(json_response['error']['details']['email']).to be_present- end- end-- context 'without authentication' do- before { request.headers['Authorization'] = nil }-- it 'returns unauthorized' do- patch :update, params: { id: 'me', user: { first_name: 'Updated' } }-- expect(response).to have_http_status(:unauthorized)- expect(json_response['error']['code']).to eq('authentication_required')- end- end- end-enddiff --git a/api/spec/controllers/spree/api/v3/store/orders/line_items_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/orders/line_items_controller_spec.rbindex 0b734fe7da..58f86a045d 100644--- a/api/spec/controllers/spree/api/v3/store/orders/line_items_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/orders/line_items_controller_spec.rb@@ -18,7 +18,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controdescribe 'POST #create' doit 'adds a line item to the order' doexpect do- post :create, params: { order_id: order.to_param, line_item: { variant_id: variant.prefix_id, quantity: 2 } }+ post :create, params: { order_id: order.to_param, variant_id: variant.prefix_id, quantity: 2 }end.to change(Spree::LineItem, :count).by(1)expect(response).to have_http_status(:created)@@ -27,32 +27,32 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controendit 'defaults quantity to 1' do- post :create, params: { order_id: order.to_param, line_item: { variant_id: variant.prefix_id } }+ post :create, params: { order_id: order.to_param, variant_id: variant.prefix_id }expect(response).to have_http_status(:created)expect(json_response['quantity']).to eq(1)endit 'updates order totals' do- post :create, params: { order_id: order.to_param, line_item: { variant_id: variant.prefix_id, quantity: 2 } }+ post :create, params: { order_id: order.to_param, variant_id: variant.prefix_id, quantity: 2 }expect(order.reload.item_total).to be > 0endcontext 'with order token (guest)' do- let(:guest_order) { create(:order, store: store) }+ let(:guest_order) { create(:order, user: nil, store: store) }before { request.headers['Authorization'] = nil }it 'adds line item with valid order token' dorequest.headers['X-Spree-Order-Token'] = guest_order.token- post :create, params: { order_id: guest_order.to_param, line_item: { variant_id: variant.prefix_id, quantity: 1 } }+ post :create, params: { order_id: guest_order.to_param, variant_id: variant.prefix_id, quantity: 1 }expect(response).to have_http_status(:created)endit 'returns forbidden without order token' do- post :create, params: { order_id: guest_order.to_param, line_item: { variant_id: variant.prefix_id, quantity: 1 } }+ post :create, params: { order_id: guest_order.to_param, variant_id: variant.prefix_id, quantity: 1 }expect(response).to have_http_status(:forbidden)expect(json_response['error']['code']).to eq('access_denied')@@ -62,7 +62,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controcontext 'validation errors' doit 'returns error for invalid variant' do- post :create, params: { order_id: order.to_param, line_item: { variant_id: 0, quantity: 1 } }+ post :create, params: { order_id: order.to_param, variant_id: 0, quantity: 1 }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('variant_not_found')@@ -72,7 +72,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controcontext 'error handling' doit 'returns not found for non-existent order' do- post :create, params: { order_id: 'invalid', line_item: { variant_id: variant.prefix_id, quantity: 1 } }+ post :create, params: { order_id: 'invalid', variant_id: variant.prefix_id, quantity: 1 }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('order_not_found')@@ -82,7 +82,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controit 'returns forbidden for other users order' doother_order = create(:order, store: store)- post :create, params: { order_id: other_order.to_param, line_item: { variant_id: variant.prefix_id, quantity: 1 } }+ post :create, params: { order_id: other_order.to_param, variant_id: variant.prefix_id, quantity: 1 }expect(response).to have_http_status(:forbidden)expect(json_response['error']['code']).to eq('access_denied')@@ -94,7 +94,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controlet!(:line_item) { create(:line_item, order: order, variant: variant, quantity: 1) }it 'updates line item quantity' do- patch :update, params: { order_id: order.to_param, id: line_item.prefix_id, line_item: { quantity: 5 } }+ patch :update, params: { order_id: order.to_param, id: line_item.prefix_id, quantity: 5 }expect(response).to have_http_status(:ok)expect(line_item.reload.quantity).to eq(5)@@ -102,14 +102,14 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controit 'updates order totals' dooriginal_total = order.item_total- patch :update, params: { order_id: order.to_param, id: line_item.prefix_id, line_item: { quantity: 5 } }+ patch :update, params: { order_id: order.to_param, id: line_item.prefix_id, quantity: 5 }expect(order.reload.item_total).to be > original_totalendcontext 'error handling' doit 'returns not found for non-existent line item' do- patch :update, params: { order_id: order.to_param, id: 0, line_item: { quantity: 5 } }+ patch :update, params: { order_id: order.to_param, id: 0, quantity: 5 }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('line_item_not_found')@@ -120,7 +120,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::LineItemsController, type: :controother_order = create(:order, store: store)other_line_item = create(:line_item, order: other_order, variant: variant)- patch :update, params: { order_id: other_order.to_param, id: other_line_item.prefix_id, line_item: { quantity: 5 } }+ patch :update, params: { order_id: other_order.to_param, id: other_line_item.prefix_id, quantity: 5 }expect(response).to have_http_status(:forbidden)expect(json_response['error']['code']).to eq('access_denied')diff --git a/api/spec/controllers/spree/api/v3/store/orders/payments_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/orders/payments_controller_spec.rbindex 1e308785e0..0940eec3fb 100644--- a/api/spec/controllers/spree/api/v3/store/orders/payments_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/orders/payments_controller_spec.rb@@ -30,7 +30,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::PaymentsController, type: :controlendcontext 'with order token (guest)' do- let(:guest_order) { create(:order_with_line_items, store: store, state: 'payment') }+ let(:guest_order) { create(:order_with_line_items, user: nil, store: store, state: 'payment') }let!(:guest_payment) { create(:payment, order: guest_order, payment_method: payment_method) }before { request.headers['Authorization'] = nil }diff --git a/api/spec/controllers/spree/api/v3/store/orders/shipments_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/orders/shipments_controller_spec.rbindex 6dbafec5ed..5208caffcc 100644--- a/api/spec/controllers/spree/api/v3/store/orders/shipments_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/orders/shipments_controller_spec.rb@@ -31,7 +31,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::ShipmentsController, type: :controcontext 'with order token (guest)' dolet(:guest_order) do- create(:order_with_line_items, store: store, state: 'delivery').tap do |o|+ create(:order_with_line_items, user: nil, store: store, state: 'delivery').tap do |o|o.create_proposed_shipmentso.reloadend@@ -117,7 +117,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::ShipmentsController, type: :contropatch :update, params: {order_id: order.to_param,id: shipment.to_param,- shipment: { selected_shipping_rate_id: shipping_rate.to_param }+ selected_shipping_rate_id: shipping_rate.to_param}expect(response).to have_http_status(:ok)@@ -129,7 +129,7 @@ RSpec.describe Spree::Api::V3::Store::Orders::ShipmentsController, type: :contropatch :update, params: {order_id: order.to_param,id: shipment.to_param,- shipment: { selected_shipping_rate_id: 'invalid' }+ selected_shipping_rate_id: 'invalid'}expect(response).to have_http_status(:not_found)diff --git a/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rbindex 4a3ac7636a..a6a9211445 100644--- a/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rb@@ -119,7 +119,7 @@ RSpec.describe Spree::Api::V3::Store::OrdersController, type: :controller doendcontext 'with order token' do- let(:guest_order) { create(:order_with_line_items, store: store) }+ let(:guest_order) { create(:order_with_line_items, user: nil, store: store) }it 'returns the order for guest with valid token' dorequest.headers['X-Spree-Order-Token'] = guest_order.token@@ -178,14 +178,14 @@ RSpec.describe Spree::Api::V3::Store::OrdersController, type: :controller doendit 'updates the order email' do- patch :update, params: { id: order.to_param, order: { email: '[email protected]' } }+ patch :update, params: { id: order.to_param, email: '[email protected]' }expect(response).to have_http_status(:ok)expect(order.reload.email).to eq('[email protected]')endit 'updates special instructions' do- patch :update, params: { id: order.to_param, order: { special_instructions: 'Leave at door' } }+ patch :update, params: { id: order.to_param, special_instructions: 'Leave at door' }expect(response).to have_http_status(:ok)expect(order.reload.special_instructions).to eq('Leave at door')@@ -193,11 +193,11 @@ RSpec.describe Spree::Api::V3::Store::OrdersController, type: :controller doendcontext 'with order token' do- let(:guest_order) { create(:order_with_line_items, store: store) }+ let(:guest_order) { create(:order_with_line_items, user: nil, store: store) }it 'updates order for guest with valid token' dorequest.headers['X-Spree-Order-Token'] = guest_order.token- patch :update, params: { id: guest_order.to_param, order: { email: '[email protected]' } }+ patch :update, params: { id: guest_order.to_param, email: '[email protected]' }expect(response).to have_http_status(:ok)expect(guest_order.reload.email).to eq('[email protected]')@@ -211,7 +211,7 @@ RSpec.describe Spree::Api::V3::Store::OrdersController, type: :controller doit 'returns forbidden for other users order' doother_order = create(:order_with_line_items, store: store)- patch :update, params: { id: other_order.to_param, order: { email: '[email protected]' } }+ patch :update, params: { id: other_order.to_param, email: '[email protected]' }expect(response).to have_http_status(:forbidden)expect(json_response['error']['code']).to eq('access_denied')diff --git a/api/spec/controllers/spree/api/v3/store/wishlist_items_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/wishlist_items_controller_spec.rbindex 9412afa464..074ca990a1 100644--- a/api/spec/controllers/spree/api/v3/store/wishlist_items_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/wishlist_items_controller_spec.rb@@ -21,7 +21,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerit 'adds item to wishlist' doexpect {- post :create, params: { wishlist_id: wishlist.prefix_id, wished_item: { variant_id: new_variant.prefix_id, quantity: 3 } }+ post :create, params: { wishlist_id: wishlist.prefix_id, variant_id: new_variant.prefix_id, quantity: 3 }}.to change(Spree::WishedItem, :count).by(1)expect(response).to have_http_status(:created)@@ -31,7 +31,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllercontext 'validation errors' doit 'returns errors for missing variant_id' do- post :create, params: { wishlist_id: wishlist.prefix_id, wished_item: { quantity: 1 } }+ post :create, params: { wishlist_id: wishlist.prefix_id, quantity: 1 }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -39,7 +39,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerendit 'returns errors for invalid variant_id' do- post :create, params: { wishlist_id: wishlist.prefix_id, wished_item: { variant_id: 0, quantity: 1 } }+ post :create, params: { wishlist_id: wishlist.prefix_id, variant_id: 0, quantity: 1 }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -52,7 +52,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerother_user = create(:user)other_wishlist = create(:wishlist, user: other_user, store: store)- post :create, params: { wishlist_id: other_wishlist.prefix_id, wished_item: { variant_id: new_variant.prefix_id, quantity: 1 } }+ post :create, params: { wishlist_id: other_wishlist.prefix_id, variant_id: new_variant.prefix_id, quantity: 1 }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')@@ -60,7 +60,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerendit 'returns not found for non-existent wishlist' do- post :create, params: { wishlist_id: 0, wished_item: { variant_id: new_variant.prefix_id, quantity: 1 } }+ post :create, params: { wishlist_id: 0, variant_id: new_variant.prefix_id, quantity: 1 }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')@@ -71,7 +71,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerbefore { request.headers['Authorization'] = nil }it 'returns unauthorized' do- post :create, params: { wishlist_id: wishlist.prefix_id, wished_item: { variant_id: new_variant.prefix_id, quantity: 1 } }+ post :create, params: { wishlist_id: wishlist.prefix_id, variant_id: new_variant.prefix_id, quantity: 1 }expect(response).to have_http_status(:unauthorized)expect(json_response['error']['code']).to eq('authentication_required')@@ -82,7 +82,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerdescribe 'PATCH #update' doit 'updates wished item quantity' do- patch :update, params: { wishlist_id: wishlist.prefix_id, id: wished_item.prefix_id, wished_item: { quantity: 5 } }+ patch :update, params: { wishlist_id: wishlist.prefix_id, id: wished_item.prefix_id, quantity: 5 }expect(response).to have_http_status(:ok)expect(wished_item.reload.quantity).to eq(5)@@ -90,7 +90,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllercontext 'validation errors' doit 'returns errors for invalid quantity' do- patch :update, params: { wishlist_id: wishlist.prefix_id, id: wished_item.prefix_id, wished_item: { quantity: 0 } }+ patch :update, params: { wishlist_id: wishlist.prefix_id, id: wished_item.prefix_id, quantity: 0 }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -100,7 +100,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllercontext 'error handling' doit 'returns not found for non-existent item' do- patch :update, params: { wishlist_id: wishlist.prefix_id, id: 0, wished_item: { quantity: 5 } }+ patch :update, params: { wishlist_id: wishlist.prefix_id, id: 0, quantity: 5 }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')@@ -112,7 +112,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistItemsController, type: :controllerother_wishlist = create(:wishlist, user: other_user, store: store)other_item = create(:wished_item, wishlist: other_wishlist, variant: variant)- patch :update, params: { wishlist_id: other_wishlist.prefix_id, id: other_item.prefix_id, wished_item: { quantity: 5 } }+ patch :update, params: { wishlist_id: other_wishlist.prefix_id, id: other_item.prefix_id, quantity: 5 }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')diff --git a/api/spec/controllers/spree/api/v3/store/wishlists_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/wishlists_controller_spec.rbindex 5c39705d84..e515d76ac1 100644--- a/api/spec/controllers/spree/api/v3/store/wishlists_controller_spec.rb+++ b/api/spec/controllers/spree/api/v3/store/wishlists_controller_spec.rb@@ -83,7 +83,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller dodescribe 'POST #create' doit 'creates a new wishlist' doexpect {- post :create, params: { wishlist: { name: 'My New Wishlist' } }+ post :create, params: { name: 'My New Wishlist' }}.to change(Spree::Wishlist, :count).by(1)expect(response).to have_http_status(:created)@@ -91,20 +91,20 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller doendit 'associates wishlist with current user' do- post :create, params: { wishlist: { name: 'Test Wishlist' } }+ post :create, params: { name: 'Test Wishlist' }expect(Spree::Wishlist.last.user_id).to eq(user.id)endit 'associates wishlist with current store' do- post :create, params: { wishlist: { name: 'Test Wishlist' } }+ post :create, params: { name: 'Test Wishlist' }expect(Spree::Wishlist.last.store_id).to eq(store.id)endcontext 'validation errors' doit 'returns errors for blank name' do- post :create, params: { wishlist: { name: '' } }+ post :create, params: { name: '' }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -117,7 +117,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller dobefore { request.headers['Authorization'] = nil }it 'returns unauthorized' do- post :create, params: { wishlist: { name: 'Test' } }+ post :create, params: { name: 'Test' }expect(response).to have_http_status(:unauthorized)expect(json_response['error']['code']).to eq('authentication_required')@@ -127,7 +127,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller dodescribe 'PATCH #update' doit 'updates the wishlist name' do- patch :update, params: { id: wishlist.prefix_id, wishlist: { name: 'Updated Name' } }+ patch :update, params: { id: wishlist.prefix_id, name: 'Updated Name' }expect(response).to have_http_status(:ok)expect(wishlist.reload.name).to eq('Updated Name')@@ -135,7 +135,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller docontext 'validation errors' doit 'returns errors for blank name' do- patch :update, params: { id: wishlist.prefix_id, wishlist: { name: '' } }+ patch :update, params: { id: wishlist.prefix_id, name: '' }expect(response).to have_http_status(:unprocessable_entity)expect(json_response['error']['code']).to eq('validation_error')@@ -148,7 +148,7 @@ RSpec.describe Spree::Api::V3::Store::WishlistsController, type: :controller doother_user = create(:user)other_wishlist = create(:wishlist, user: other_user, store: store)- patch :update, params: { id: other_wishlist.prefix_id, wishlist: { name: 'Hacked' } }+ patch :update, params: { id: other_wishlist.prefix_id, name: 'Hacked' }expect(response).to have_http_status(:not_found)expect(json_response['error']['code']).to eq('record_not_found')diff --git a/api/spec/integration/spree/api/v3/store/addresses_spec.rb b/api/spec/integration/spree/api/v3/store/addresses_spec.rbindex cd87ed918f..5ee4a62a99 100644--- a/api/spec/integration/spree/api/v3/store/addresses_spec.rb+++ b/api/spec/integration/spree/api/v3/store/addresses_spec.rb@@ -9,7 +9,7 @@ RSpec.describe 'Addresses API', type: :request, swagger_doc: 'api-reference/storlet!(:state) { create(:state, country: country) }let!(:address) { create(:address, user: user, country: country, state: state) }- path '/api/v3/store/customers/me/addresses' do+ path '/api/v3/store/customer/addresses' doget 'List customer addresses' dotags 'Addresses'produces 'application/json'@@ -59,24 +59,19 @@ RSpec.describe 'Addresses API', type: :request, swagger_doc: 'api-reference/storparameter name: :body, in: :body, schema: {type: :object,properties: {- address: {- type: :object,- properties: {- firstname: { type: :string },- lastname: { type: :string },- address1: { type: :string },- address2: { type: :string },- city: { type: :string },- zipcode: { type: :string },- phone: { type: :string },- company: { type: :string },- country_iso: { type: :string, description: 'ISO 3166-1 alpha-2 country code (e.g., "US", "DE")' },- state_abbr: { type: :string, description: 'ISO 3166-2 subdivision code without country prefix (e.g., "CA", "NY")' },- state_name: { type: :string, description: 'State name - for countries without predefined states' }- },- required: %w[firstname lastname address1 city zipcode country_iso]- }- }+ firstname: { type: :string },+ lastname: { type: :string },+ address1: { type: :string },+ address2: { type: :string },+ city: { type: :string },+ zipcode: { type: :string },+ phone: { type: :string },+ company: { type: :string },+ country_iso: { type: :string, description: 'ISO 3166-1 alpha-2 country code (e.g., "US", "DE")' },+ state_abbr: { type: :string, description: 'ISO 3166-2 subdivision code without country prefix (e.g., "CA", "NY")' },+ state_name: { type: :string, description: 'State name - for countries without predefined states' }+ },+ required: %w[firstname lastname address1 city zipcode country_iso]}response '201', 'address created' do@@ -84,16 +79,14 @@ RSpec.describe 'Addresses API', type: :request, swagger_doc: 'api-reference/storlet(:'Authorization') { "Bearer #{jwt_token}" }let(:body) do{- address: {- firstname: 'John',- lastname: 'Doe',- address1: '123 Main St',- city: 'New York',- zipcode: '10001',- phone: '+1 555 123 4567',- country_iso: country.iso,- state_abbr: state.abbr- }+ firstname: 'John',+ lastname: 'Doe',+ address1: '123 Main St',+ city: 'New York',+ zipcode: '10001',+ phone: '+1 555 123 4567',+ country_iso: country.iso,+ state_abbr: state.abbr}end@@ -111,7 +104,7 @@ RSpec.describe 'Addresses API', type: :request, swagger_doc: 'api-reference/storresponse '422', 'validation error' dolet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }- let(:body) { { address: { firstname: '' } } }+ let(:body) { { firstname: '' } }schema '$ref' => '#/components/schemas/ErrorResponse'@@ -120,7 +113,7 @@ RSpec.describe 'Addresses API', type: :request, swagger_doc: 'api-reference/storendend- path '/api/v3/store/customers/me/addresses/{id}' do+ path '/api/v3/store/customer/addresses/{id}' doget 'Get an address' dotags 'Addresses'produces 'application/json'@@ -163,15 +156,10 @@ RSpec.describe 'Addresses API', type: :request, swagger_doc: 'api-reference/storparameter name: :body, in: :body, schema: {type: :object,properties: {- address: {- type: :object,- properties: {- firstname: { type: :string },- lastname: { type: :string },- address1: { type: :string },- city: { type: :string }- }- }+ firstname: { type: :string },+ lastname: { type: :string },+ address1: { type: :string },+ city: { type: :string }}}@@ -179,7 +167,7 @@ RSpec.describe 'Addresses API', type: :request, swagger_doc: 'api-reference/storlet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:id) { address.to_param }- let(:body) { { address: { city: 'Los Angeles' } } }+ let(:body) { { city: 'Los Angeles' } }schema '$ref' => '#/components/schemas/StoreAddress'diff --git a/api/spec/integration/spree/api/v3/store/auth_spec.rb b/api/spec/integration/spree/api/v3/store/auth_spec.rbindex e0990611be..1393ee8833 100644--- a/api/spec/integration/spree/api/v3/store/auth_spec.rb+++ b/api/spec/integration/spree/api/v3/store/auth_spec.rb@@ -81,31 +81,23 @@ RSpec.describe 'Authentication API', type: :request, swagger_doc: 'api-referenceparameter name: :body, in: :body, schema: {type: :object,properties: {- user: {- type: :object,- properties: {- email: { type: :string, format: 'email' },- password: { type: :string, minLength: 6 },- password_confirmation: { type: :string },- first_name: { type: :string },- last_name: { type: :string }- },- required: %w[email password]- }+ email: { type: :string, format: 'email' },+ password: { type: :string, minLength: 6 },+ password_confirmation: { type: :string },+ first_name: { type: :string },+ last_name: { type: :string }},- required: %w[user]+ required: %w[email password]}response '201', 'registration successful' dolet(:'x-spree-api-key') { api_key.token }let(:body) do{- user: {- email: '[email protected]',- password: 'password123',- first_name: 'John',- last_name: 'Doe'- }+ email: '[email protected]',+ password: 'password123',+ first_name: 'John',+ last_name: 'Doe'}end@@ -127,10 +119,8 @@ RSpec.describe 'Authentication API', type: :request, swagger_doc: 'api-referencelet(:'x-spree-api-key') { api_key.token }let(:body) do{- user: {- email: existing_user.email,- password: 'password123'- }+ email: existing_user.email,+ password: 'password123'}enddiff --git a/api/spec/integration/spree/api/v3/store/customers_spec.rb b/api/spec/integration/spree/api/v3/store/customers_spec.rbindex 2eff8960ca..c36c273374 100644--- a/api/spec/integration/spree/api/v3/store/customers_spec.rb+++ b/api/spec/integration/spree/api/v3/store/customers_spec.rb@@ -59,23 +59,18 @@ RSpec.describe 'Customers API', type: :request, swagger_doc: 'api-reference/storparameter name: :body, in: :body, schema: {type: :object,properties: {- user: {- type: :object,- properties: {- first_name: { type: :string },- last_name: { type: :string },- email: { type: :string, format: 'email' },- password: { type: :string },- password_confirmation: { type: :string }- }- }+ first_name: { type: :string },+ last_name: { type: :string },+ email: { type: :string, format: 'email' },+ password: { type: :string },+ password_confirmation: { type: :string }}}response '200', 'profile updated' dolet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }- let(:body) { { user: { first_name: 'Updated', last_name: 'Name' } } }+ let(:body) { { first_name: 'Updated', last_name: 'Name' } }schema '$ref' => '#/components/schemas/StoreUser'@@ -89,7 +84,7 @@ RSpec.describe 'Customers API', type: :request, swagger_doc: 'api-reference/storresponse '422', 'validation error' dolet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }- let(:body) { { user: { email: '' } } }+ let(:body) { { email: '' } }schema '$ref' => '#/components/schemas/ErrorResponse'diff --git a/api/spec/integration/spree/api/v3/store/line_items_spec.rb b/api/spec/integration/spree/api/v3/store/line_items_spec.rbindex 85769a4a2f..e919c2e72f 100644--- a/api/spec/integration/spree/api/v3/store/line_items_spec.rb+++ b/api/spec/integration/spree/api/v3/store/line_items_spec.rb@@ -40,7 +40,7 @@ RSpec.describe 'Line Items API', type: :request, swagger_doc: 'api-reference/stolet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:order_id) { order.to_param }- let(:body) { { line_item: { variant_id: new_variant.prefix_id, quantity: 2 } } }+ let(:body) { { variant_id: new_variant.prefix_id, quantity: 2 } }schema '$ref' => '#/components/schemas/StoreLineItem'@@ -54,7 +54,7 @@ RSpec.describe 'Line Items API', type: :request, swagger_doc: 'api-reference/stolet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:order_id) { order.to_param }- let(:body) { { line_item: { variant_id: 'invalid', quantity: 1 } } }+ let(:body) { { variant_id: 'invalid', quantity: 1 } }schema '$ref' => '#/components/schemas/ErrorResponse'@@ -65,7 +65,7 @@ RSpec.describe 'Line Items API', type: :request, swagger_doc: 'api-reference/stolet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:order_id) { 'non-existent' }- let(:body) { { line_item: { variant_id: variant.prefix_id, quantity: 1 } } }+ let(:body) { { variant_id: variant.prefix_id, quantity: 1 } }schema '$ref' => '#/components/schemas/ErrorResponse'@@ -100,7 +100,7 @@ RSpec.describe 'Line Items API', type: :request, swagger_doc: 'api-reference/stolet(:'Authorization') { "Bearer #{jwt_token}" }let(:order_id) { order.to_param }let(:id) { line_item.to_param }- let(:body) { { line_item: { quantity: 5 } } }+ let(:body) { { quantity: 5 } }schema '$ref' => '#/components/schemas/StoreLineItem'diff --git a/api/spec/integration/spree/api/v3/store/orders_spec.rb b/api/spec/integration/spree/api/v3/store/orders_spec.rbindex 9795569611..baa367e575 100644--- a/api/spec/integration/spree/api/v3/store/orders_spec.rb+++ b/api/spec/integration/spree/api/v3/store/orders_spec.rb@@ -138,9 +138,10 @@ RSpec.describe 'Orders API', type: :request, swagger_doc: 'api-reference/store.yendresponse '200', 'order found (guest with token)' do+ let(:guest_order) { create(:order_with_line_items, store: store, user: nil) }let(:'x-spree-api-key') { api_key.token }- let(:id) { order.to_param }- let(:order_token) { order.token }+ let(:id) { guest_order.to_param }+ let(:order_token) { guest_order.token }schema '$ref' => '#/components/schemas/StoreOrder'@@ -184,15 +185,10 @@ RSpec.describe 'Orders API', type: :request, swagger_doc: 'api-reference/store.yparameter name: :body, in: :body, schema: {type: :object,properties: {- order: {- type: :object,- properties: {- email: { type: :string, format: 'email' },- special_instructions: { type: :string },- bill_address_attributes: { '$ref' => '#/components/schemas/StoreAddress' },- ship_address_attributes: { '$ref' => '#/components/schemas/StoreAddress' }- }- }+ email: { type: :string, format: 'email' },+ special_instructions: { type: :string },+ bill_address: { '$ref' => '#/components/schemas/StoreAddress' },+ ship_address: { '$ref' => '#/components/schemas/StoreAddress' }}}@@ -200,7 +196,7 @@ RSpec.describe 'Orders API', type: :request, swagger_doc: 'api-reference/store.ylet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:id) { order.to_param }- let(:body) { { order: { special_instructions: 'Leave at door' } } }+ let(:body) { { special_instructions: 'Leave at door' } }schema '$ref' => '#/components/schemas/StoreOrder'@@ -215,7 +211,7 @@ RSpec.describe 'Orders API', type: :request, swagger_doc: 'api-reference/store.ylet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:id) { completed_order.to_param }- let(:body) { { order: { special_instructions: 'Test' } } }+ let(:body) { { special_instructions: 'Test' } }schema '$ref' => '#/components/schemas/ErrorResponse'diff --git a/api/spec/integration/spree/api/v3/store/shipments_spec.rb b/api/spec/integration/spree/api/v3/store/shipments_spec.rbindex fa04d73cd7..cda75fd583 100644--- a/api/spec/integration/spree/api/v3/store/shipments_spec.rb+++ b/api/spec/integration/spree/api/v3/store/shipments_spec.rb@@ -108,15 +108,9 @@ RSpec.describe 'Shipments API', type: :request, swagger_doc: 'api-reference/storparameter name: :body, in: :body, schema: {type: :object,properties: {- shipment: {- type: :object,- properties: {- selected_shipping_rate_id: { type: :string, description: 'Shipping rate ID to select' }- },- required: %w[selected_shipping_rate_id]- }+ selected_shipping_rate_id: { type: :string, description: 'Shipping rate ID to select' }},- required: %w[shipment]+ required: %w[selected_shipping_rate_id]}response '200', 'shipping rate selected' do@@ -126,7 +120,7 @@ RSpec.describe 'Shipments API', type: :request, swagger_doc: 'api-reference/storlet(:order_id) { order.to_param }let(:id) { shipment.to_param }let(:token) { order.token }- let(:body) { { shipment: { selected_shipping_rate_id: shipping_rate.to_param } } }+ let(:body) { { selected_shipping_rate_id: shipping_rate.to_param } }schema '$ref' => '#/components/schemas/StoreShipment'@@ -139,7 +133,7 @@ RSpec.describe 'Shipments API', type: :request, swagger_doc: 'api-reference/storlet(:order_id) { order.to_param }let(:id) { shipment.to_param }let(:token) { order.token }- let(:body) { { shipment: { selected_shipping_rate_id: 'shprt_invalid' } } }+ let(:body) { { selected_shipping_rate_id: 'shprt_invalid' } }schema '$ref' => '#/components/schemas/ErrorResponse'diff --git a/api/spec/integration/spree/api/v3/store/wishlists_spec.rb b/api/spec/integration/spree/api/v3/store/wishlists_spec.rbindex b18094bb95..13ef6c1d4d 100644--- a/api/spec/integration/spree/api/v3/store/wishlists_spec.rb+++ b/api/spec/integration/spree/api/v3/store/wishlists_spec.rb@@ -60,22 +60,17 @@ RSpec.describe 'Wishlists API', type: :request, swagger_doc: 'api-reference/storparameter name: :body, in: :body, schema: {type: :object,properties: {- wishlist: {- type: :object,- properties: {- name: { type: :string },- is_private: { type: :boolean },- is_default: { type: :boolean }- },- required: %w[name]- }- }+ name: { type: :string },+ is_private: { type: :boolean },+ is_default: { type: :boolean }+ },+ required: %w[name]}response '201', 'wishlist created' dolet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }- let(:body) { { wishlist: { name: 'Birthday Ideas', is_private: true } } }+ let(:body) { { name: 'Birthday Ideas', is_private: true } }schema '$ref' => '#/components/schemas/StoreWishlist'@@ -89,7 +84,7 @@ RSpec.describe 'Wishlists API', type: :request, swagger_doc: 'api-reference/storresponse '422', 'validation error' dolet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }- let(:body) { { wishlist: { name: '' } } }+ let(:body) { { name: '' } }schema '$ref' => '#/components/schemas/ErrorResponse'@@ -143,14 +138,9 @@ RSpec.describe 'Wishlists API', type: :request, swagger_doc: 'api-reference/storparameter name: :body, in: :body, schema: {type: :object,properties: {- wishlist: {- type: :object,- properties: {- name: { type: :string },- is_private: { type: :boolean },- is_default: { type: :boolean }- }- }+ name: { type: :string },+ is_private: { type: :boolean },+ is_default: { type: :boolean }}}@@ -158,7 +148,7 @@ RSpec.describe 'Wishlists API', type: :request, swagger_doc: 'api-reference/storlet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:id) { wishlist.to_param }- let(:body) { { wishlist: { name: 'Updated Name' } } }+ let(:body) { { name: 'Updated Name' } }schema '$ref' => '#/components/schemas/StoreWishlist'@@ -213,7 +203,7 @@ RSpec.describe 'Wishlists API', type: :request, swagger_doc: 'api-reference/storlet(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:wishlist_id) { wishlist.to_param }- let(:body) { { wished_item: { variant_id: new_variant.id.to_s, quantity: 1 } } }+ let(:body) { { variant_id: new_variant.prefix_id, quantity: 1 } }schema '$ref' => '#/components/schemas/StoreWishedItem'diff --git a/api/spec/services/spree/api/v3/orders/update_spec.rb b/api/spec/services/spree/api/v3/orders/update_spec.rbnew file mode 100644index 0000000000..06af676c03--- /dev/null+++ b/api/spec/services/spree/api/v3/orders/update_spec.rb@@ -0,0 +1,275 @@+require 'spec_helper'++RSpec.describe Spree::Api::V3::Orders::Update do+ let(:store) { create(:store, supported_currencies: 'USD,EUR,GBP') }+ let(:user) { create(:user) }+ let(:order) { create(:order_with_line_items, user: user, store: store, currency: 'USD') }++ describe '#call' do+ subject { described_class.call(order: order, params: params) }++ describe 'updating email' do+ let(:params) { { email: '[email protected]' } }++ it 'updates the order email' do+ expect(subject).to be_success+ expect(order.reload.email).to eq('[email protected]')+ end+ end++ describe 'updating special_instructions' do+ let(:params) { { special_instructions: 'Leave at the door' } }++ it 'updates the special instructions' do+ expect(subject).to be_success+ expect(order.reload.special_instructions).to eq('Leave at the door')+ end+ end++ describe 'updating currency' do+ context 'with supported currency' do+ let(:params) { { currency: 'EUR' } }++ it 'updates the currency' do+ expect(subject).to be_success+ expect(order.reload.currency).to eq('EUR')+ end++ it 'is case-insensitive' do+ result = described_class.call(order: order, params: { currency: 'eur' })+ expect(result).to be_success+ expect(order.reload.currency).to eq('EUR')+ end+ end++ context 'with unsupported currency' do+ let(:params) { { currency: 'JPY' } }++ it 'returns failure' do+ expect(subject).to be_failure+ end++ it 'does not change the currency' do+ subject+ expect(order.reload.currency).to eq('USD')+ end+ end+ end++ describe 'updating ship_address' do+ let(:country) { Spree::Country.find_by(iso: 'US') || create(:country, iso: 'US') }+ let!(:state) { country.states.find_by(abbr: 'NY') || create(:state, country: country, abbr: 'NY', name: 'New York') }++ context 'with new address attributes' do+ let(:params) do+ {+ ship_address: {+ firstname: 'John',+ lastname: 'Doe',+ address1: '123 Main St',+ city: 'New York',+ zipcode: '10001',+ country_iso: 'US',+ state_abbr: 'NY',+ phone: '555-1234'+ }+ }+ end++ it 'creates a new shipping address' do+ expect(subject).to be_success+ address = order.reload.ship_address+ expect(address.firstname).to eq('John')+ expect(address.lastname).to eq('Doe')+ expect(address.address1).to eq('123 Main St')+ expect(address.city).to eq('New York')+ expect(address.zipcode).to eq('10001')+ expect(address.country.iso).to eq('US')+ expect(address.state.abbr).to eq('NY')+ end++ context 'when order has address checkout step' do+ let(:order) { create(:order_with_line_items, user: user, store: store, state: 'delivery') }++ it 'reverts order to address state' do+ expect(subject).to be_success+ expect(order.reload.state).to eq('address')+ end+ end++ context 'when order is in cart state' do+ let(:order) { create(:order_with_line_items, user: user, store: store, state: 'cart') }++ it 'does not change order state' do+ expect(subject).to be_success+ expect(order.reload.state).to eq('cart')+ end+ end+ end++ context 'with existing address by prefix_id' do+ let(:existing_address) { create(:address, user: user) }+ let(:params) { { ship_address: { id: existing_address.prefix_id } } }++ it 'uses the existing address' do+ expect(subject).to be_success+ expect(order.reload.ship_address_id).to eq(existing_address.id)+ end+ end++ context 'with ship_address_id parameter' do+ let(:existing_address) { create(:address, user: user) }+ let(:params) { { ship_address_id: existing_address.prefix_id } }++ it 'uses the existing address' do+ expect(subject).to be_success+ expect(order.reload.ship_address_id).to eq(existing_address.id)+ end+ end+ end++ describe 'updating bill_address' do+ let(:country) { Spree::Country.find_by(iso: 'US') || create(:country, iso: 'US') }+ let!(:state) { country.states.find_by(abbr: 'CA') || create(:state, country: country, abbr: 'CA', name: 'California') }++ context 'with new address attributes' do+ let(:params) do+ {+ bill_address: {+ firstname: 'Jane',+ lastname: 'Smith',+ address1: '456 Oak Ave',+ city: 'Los Angeles',+ zipcode: '90001',+ country_iso: 'US',+ state_abbr: 'CA',+ phone: '555-5678'+ }+ }+ end++ it 'creates a new billing address' do+ expect(subject).to be_success+ address = order.reload.bill_address+ expect(address.firstname).to eq('Jane')+ expect(address.lastname).to eq('Smith')+ expect(address.address1).to eq('456 Oak Ave')+ expect(address.city).to eq('Los Angeles')+ end+ end++ context 'with existing address by prefix_id' do+ let(:existing_address) { create(:address, user: user) }+ let(:params) { { bill_address: { id: existing_address.prefix_id } } }++ it 'uses the existing address' do+ expect(subject).to be_success+ expect(order.reload.bill_address_id).to eq(existing_address.id)+ end+ end++ context 'with bill_address_id parameter' do+ let(:existing_address) { create(:address, user: user) }+ let(:params) { { bill_address_id: existing_address.prefix_id } }++ it 'uses the existing address' do+ expect(subject).to be_success+ expect(order.reload.bill_address_id).to eq(existing_address.id)+ end+ end+ end++ describe 'address ownership validation' do+ let(:other_user) { create(:user) }+ let(:other_users_address) { create(:address, user: other_user) }++ context 'when using another users address for ship_address' do+ let(:params) { { ship_address: { id: other_users_address.prefix_id } } }++ it 'returns failure' do+ expect(subject).to be_failure+ expect(subject.error).to be_present+ end+ end++ context 'when using another users address for bill_address' do+ let(:params) { { bill_address: { id: other_users_address.prefix_id } } }++ it 'returns failure' do+ expect(subject).to be_failure+ expect(subject.error).to be_present+ end+ end++ context 'when using guest address (no user)' do+ let(:guest_address) { create(:address, user: nil) }+ let(:params) { { ship_address_id: guest_address.prefix_id } }++ it 'allows using the address' do+ expect(subject).to be_success+ expect(order.reload.ship_address_id).to eq(guest_address.id)+ end+ end+ end++ describe 'updating multiple fields' do+ let(:country) { Spree::Country.find_by(iso: 'US') || create(:country, iso: 'US') }+ let!(:state) { country.states.find_by(abbr: 'NY') || create(:state, country: country, abbr: 'NY', name: 'New York') }++ let(:params) do+ {+ email: '[email protected]',+ special_instructions: 'Handle with care',+ ship_address: {+ firstname: 'John',+ lastname: 'Doe',+ address1: '123 Main St',+ city: 'New York',+ zipcode: '10001',+ country_iso: 'US',+ state_abbr: 'NY'+ }+ }+ end++ it 'updates all fields in a single transaction' do+ expect(subject).to be_success+ order.reload+ expect(order.email).to eq('[email protected]')+ expect(order.special_instructions).to eq('Handle with care')+ expect(order.ship_address.firstname).to eq('John')+ end+ end++ describe 'error handling' do+ context 'with invalid address prefix_id' do+ let(:params) { { ship_address_id: 'addr_invalid123' } }++ it 'returns failure' do+ expect(subject).to be_failure+ end+ end++ context 'when order save fails' do+ let(:params) { { email: '[email protected]' } }++ before do+ allow(order).to receive(:save!).and_raise(ActiveRecord::RecordInvalid.new(order))+ end++ it 'returns failure with error message' do+ expect(subject).to be_failure+ end+ end+ end++ describe 'parameter normalization' do+ let(:params) { { 'email' => '[email protected]' } }++ it 'handles string keys' do+ expect(subject).to be_success+ expect(order.reload.email).to eq('[email protected]')+ end+ end+ end+enddiff --git a/docs/api-reference/store.yaml b/docs/api-reference/store.yamlindex 619371001b..241910c22b 100644--- a/docs/api-reference/store.yaml+++ b/docs/api-reference/store.yaml@@ -40,7 +40,7 @@ info:```version: v3paths:- "/api/v3/store/customers/me/addresses":+ "/api/v3/store/customer/addresses":get:summary: List customer addressestags:@@ -128,43 +128,40 @@ paths:schema:type: objectproperties:- address:- type: object- properties:- firstname:- type: string- lastname:- type: string- address1:- type: string- address2:- type: string- city:- type: string- zipcode:- type: string- phone:- type: string- company:- type: string- country_iso:- type: string- description: ISO 3166-1 alpha-2 country code (e.g., "US", "DE")- state_abbr:- type: string- description: ISO 3166-2 subdivision code without country prefix- (e.g., "CA", "NY")- state_name:- type: string- description: State name - for countries without predefined states- required:- - firstname- - lastname- - address1- - city- - zipcode- - country_iso- "/api/v3/store/customers/me/addresses/{id}":+ firstname:+ type: string+ lastname:+ type: string+ address1:+ type: string+ address2:+ type: string+ city:+ type: string+ zipcode:+ type: string+ phone:+ type: string+ company:+ type: string+ country_iso:+ type: string+ description: ISO 3166-1 alpha-2 country code (e.g., "US", "DE")+ state_abbr:+ type: string+ description: ISO 3166-2 subdivision code without country prefix+ (e.g., "CA", "NY")+ state_name:+ type: string+ description: State name - for countries without predefined states+ required:+ - firstname+ - lastname+ - address1+ - city+ - zipcode+ - country_iso+ "/api/v3/store/customer/addresses/{id}":get:summary: Get an addresstags:@@ -237,17 +234,14 @@ paths:schema:type: objectproperties:- address:- type: object- properties:- firstname:- type: string- lastname:- type: string- address1:- type: string- city:- type: string+ firstname:+ type: string+ lastname:+ type: string+ address1:+ type: string+ city:+ type: stringdelete:summary: Delete an addresstags:@@ -361,26 +355,21 @@ paths:schema:type: objectproperties:- user:- type: object- properties:- email:- type: string- format: email- password:- type: string- minLength: 6- password_confirmation:- type: string- first_name:- type: string- last_name:- type: string- required:- - password+ email:+ type: string+ format: email+ password:+ type: string+ minLength: 6+ password_confirmation:+ type: string+ first_name:+ type: string+ last_name:+ type: stringrequired:- - user+ - password"/api/v3/store/auth/refresh":post:summary: Refresh token@@ -415,6 +404,127 @@ paths:application/json:schema:"$ref": "#/components/schemas/ErrorResponse"+ "/api/v3/store/cart":+ get:+ summary: Get current cart+ tags:+ - Cart+ security:+ - api_key: []+ bearer_auth: []+ description: |+ Returns the current shopping cart (incomplete order).+ Authenticate via JWT token for logged-in users or via order_token parameter for guests.+ parameters:+ - name: x-spree-api-key+ in: header+ required: true+ schema:+ type: string+ - name: Authorization+ in: header+ required: false+ description: Bearer JWT token for authenticated customers+ schema:+ type: string+ - name: order_token+ in: query+ required: false+ description: Order token for guest checkout+ schema:+ type: string+ responses:+ '200':+ description: cart found (authenticated)+ content:+ application/json:+ schema:+ type: object+ allOf:+ - "$ref": "#/components/schemas/StoreOrder"+ - type: object+ properties:+ token:+ type: string+ '404':+ description: no cart found+ content:+ application/json:+ schema:+ "$ref": "#/components/schemas/ErrorResponse"+ "/api/v3/store/cart/associate":+ patch:+ summary: Associate guest cart with authenticated user+ tags:+ - Cart+ security:+ - api_key: []+ bearer_auth: []+ description: |+ Associates a guest cart with the currently authenticated user.+ Requires both JWT authentication and an order token.+ The order must not be completed and must not belong to another user.+ parameters:+ - name: x-spree-api-key+ in: header+ required: true+ schema:+ type: string+ - name: Authorization+ in: header+ required: true+ description: Bearer JWT token (required)+ schema:+ type: string+ - name: x-spree-order-token+ in: header+ required: false+ description: Order token (can also be passed as query param)+ schema:+ type: string+ - name: order_token+ in: query+ required: false+ description: Order token (alternative to header)+ schema:+ type: string+ responses:+ '200':+ description: cart associated successfully+ content:+ application/json:+ schema:+ type: object+ allOf:+ - "$ref": "#/components/schemas/StoreOrder"+ - type: object+ properties:+ token:+ type: string+ '401':+ description: unauthorized - JWT required+ content:+ application/json:+ schema:+ "$ref": "#/components/schemas/ErrorResponse"+ '403':+ description: cart belongs to another user+ content:+ application/json:+ schema:+ "$ref": "#/components/schemas/ErrorResponse"+ '404':+ description: cart not found+ content:+ application/json:+ schema:+ "$ref": "#/components/schemas/ErrorResponse"+ '422':+ description: cart already completed+ content:+ application/json:+ schema:+ "$ref": "#/components/schemas/ErrorResponse""/api/v3/store/countries":get:summary: List checkout countries@@ -535,7 +645,7 @@ paths:application/json:schema:"$ref": "#/components/schemas/ErrorResponse"- "/api/v3/store/customers/me":+ "/api/v3/store/customer":get:summary: Get current customer profiletags:@@ -607,140 +717,17 @@ paths:schema:type: objectproperties:- user:- type: object- properties:- first_name:- type: string- last_name:- type: string- email:- type: string- format: email- password:- type: string- password_confirmation:- type: string- "/api/v3/store/cart":- get:- summary: Get current cart- tags:- - Cart- security:- - api_key: []- bearer_auth: []- description: |- Returns the current shopping cart (incomplete order).- Authenticate via JWT token for logged-in users or via order_token parameter for guests.- parameters:- - name: x-spree-api-key- in: header- required: true- schema:- type: string- - name: Authorization- in: header- required: false- description: Bearer JWT token for authenticated customers- schema:- type: string- - name: order_token- in: query- required: false- description: Order token for guest checkout- schema:- type: string- responses:- '200':- description: cart found- content:- application/json:- schema:- allOf:- - "$ref": "#/components/schemas/StoreOrder"- - type: object- properties:- token:- type: string- description: Order token for guest access- '404':- description: no cart found- content:- application/json:- schema:- "$ref": "#/components/schemas/ErrorResponse"- "/api/v3/store/cart/associate":- patch:- summary: Associate guest cart with authenticated user- tags:- - Cart- security:- - api_key: []- bearer_auth: []- description: |- Associates a guest cart with the currently authenticated user.- Requires both JWT authentication and an order token.- The order must not be completed and must not belong to another user.- parameters:- - name: x-spree-api-key- in: header- required: true- schema:- type: string- - name: Authorization- in: header- required: true- description: Bearer JWT token (required)- schema:- type: string- - name: x-spree-order-token- in: header- required: false- description: Order token (can also be passed as query param)- schema:- type: string- - name: order_token- in: query- required: false- description: Order token (alternative to header)- schema:- type: string- responses:- '200':- description: cart associated successfully- content:- application/json:- schema:- allOf:- - "$ref": "#/components/schemas/StoreOrder"- - type: object- properties:- token:- type: string- '401':- description: unauthorized - JWT required- content:- application/json:- schema:- "$ref": "#/components/schemas/ErrorResponse"- '403':- description: cart belongs to another user- content:- application/json:- schema:- "$ref": "#/components/schemas/ErrorResponse"- '404':- description: cart not found- content:- application/json:- schema:- "$ref": "#/components/schemas/ErrorResponse"- '422':- description: cart already completed- content:- application/json:- schema:- "$ref": "#/components/schemas/ErrorResponse"+ first_name:+ type: string+ last_name:+ type: string+ email:+ type: string+ format: email+ password:+ type: string+ password_confirmation:+ type: string"/api/v3/store/orders/{order_id}/line_items":post:summary: Add item to cart@@ -1106,18 +1093,15 @@ paths:schema:type: objectproperties:- order:- type: object- properties:- email:- type: string- format: email- special_instructions:- type: string- bill_address_attributes:- "$ref": "#/components/schemas/StoreAddress"- ship_address_attributes:- "$ref": "#/components/schemas/StoreAddress"+ email:+ type: string+ format: email+ special_instructions:+ type: string+ bill_address:+ "$ref": "#/components/schemas/StoreAddress"+ ship_address:+ "$ref": "#/components/schemas/StoreAddress""/api/v3/store/orders/{id}/next":patch:summary: Advance to next checkout step@@ -1403,7 +1387,7 @@ paths:type: string- name: order_idin: path- description: Order number or ID+ description: Order prefix IDrequired: trueschema:type: string@@ -1449,7 +1433,7 @@ paths:type: string- name: order_idin: path- description: Order number or ID+ description: Order prefix IDrequired: trueschema:type: string@@ -1751,16 +1735,11 @@ paths:schema:type: objectproperties:- shipment:- type: object- properties:- selected_shipping_rate_id:- type: string- description: Shipping rate ID to select- required:- - selected_shipping_rate_id+ selected_shipping_rate_id:+ type: string+ description: Shipping rate ID to selectrequired:- - shipment+ - selected_shipping_rate_id"/api/v3/store/store":get:summary: Get current store@@ -2012,17 +1991,14 @@ paths:schema:type: objectproperties:- wishlist:- type: object- properties:- name:- type: string- is_private:- type: boolean- is_default:- type: boolean- required:- - name+ name:+ type: string+ is_private:+ type: boolean+ is_default:+ type: boolean+ required:+ - name"/api/v3/store/wishlists/{id}":get:summary: Get a wishlist@@ -2102,15 +2078,12 @@ paths:schema:type: objectproperties:- wishlist:- type: object- properties:- name:- type: string- is_private:- type: boolean- is_default:- type: boolean+ name:+ type: string+ is_private:+ type: boolean+ is_default:+ type: booleandelete:summary: Delete a wishlisttags:@@ -2233,8 +2206,6 @@ tags:description: Individual categories- name: Countriesdescription: Available shipping countries-- name: Cart- description: Current shopping cart management- name: Ordersdescription: Shopping cart and checkout- name: Line Items@@ -2373,6 +2344,29 @@ components:- full_name- country_name- country_iso+ AdminMetafield:+ type: object+ properties:+ id:+ type: string+ name:+ type: string+ type:+ type: string+ key:+ type: string+ value:+ type: object+ display_on:+ type: string+ x-typelizer: true+ required:+ - id+ - name+ - type+ - key+ - value+ - display_onAdminOrder:type: objectproperties:@@ -2525,24 +2519,59 @@ components:- considered_risky- confirmation_delivered- store_owner_notification_delivered- AdminProduct:+ AdminPrice:type: objectproperties:id:type: string- name:+ amount:type: string- description:+ nullable: true+ amount_in_cents:+ type: number+ nullable: true+ compare_at_amount:type: stringnullable: true- slug:+ compare_at_amount_in_cents:+ type: number+ nullable: true+ currency:type: string- sku:+ nullable: true+ display_amount:+ type: string+ nullable: true+ display_compare_at_amount:+ type: string+ nullable: true+ price_list_id:+ type: string+ nullable: true+ variant_id:type: stringnullable: true- barcode:+ created_at:+ type: string+ updated_at:+ type: string+ x-typelizer: true+ required:+ - id+ - created_at+ - updated_at+ AdminProduct:+ type: object+ properties:+ id:+ type: string+ name:+ type: string+ description:type: stringnullable: true+ slug:+ type: stringmeta_description:type: stringnullable: true@@ -2562,32 +2591,23 @@ components:type: booleanin_stock:type: boolean- backorderable:- type: boolean- available:- type: boolean- price:- type: number- nullable: true- price_in_cents:- type: number- nullable: true- display_price:+ backorderable:+ type: boolean+ available:+ type: boolean+ default_variant_id:type: string- nullable: true- compare_at_price:- type: number- nullable: true- compare_at_price_in_cents:- type: number- nullable: true- display_compare_at_price:+ thumbnail_url:type: stringnullable: truetags:type: arrayitems:type: string+ price:+ "$ref": "#/components/schemas/StorePrice"+ original_price:+ "$ref": "#/components/schemas/StorePrice"images:type: arrayitems:@@ -2608,6 +2628,10 @@ components:type: arrayitems:"$ref": "#/components/schemas/StoreTaxon"+ metafields:+ type: array+ items:+ "$ref": "#/components/schemas/AdminMetafield"status:type: stringmake_active_at:@@ -2637,8 +2661,129 @@ components:- in_stock- backorderable- available+ - default_variant_id- tags+ - price+ - original_price- status+ AdminTaxon:+ type: object+ properties:+ id:+ type: string+ name:+ type: string+ permalink:+ type: string+ position:+ type: number+ depth:+ type: number+ meta_title:+ type: string+ nullable: true+ meta_description:+ type: string+ nullable: true+ meta_keywords:+ type: string+ nullable: true+ children_count:+ type: number+ created_at:+ type: string+ updated_at:+ type: string+ parent_id:+ type: string+ nullable: true+ taxonomy_id:+ type: string+ description:+ type: string+ description_html:+ type: string+ image_url:+ type: string+ nullable: true+ square_image_url:+ type: string+ nullable: true+ is_root:+ type: boolean+ is_child:+ type: boolean+ is_leaf:+ type: boolean+ parent:+ "$ref": "#/components/schemas/StoreTaxon"+ children:+ type: array+ items:+ "$ref": "#/components/schemas/StoreTaxon"+ ancestors:+ type: array+ items:+ "$ref": "#/components/schemas/StoreTaxon"+ metafields:+ type: array+ items:+ "$ref": "#/components/schemas/AdminMetafield"+ lft:+ type: number+ rgt:+ type: number+ x-typelizer: true+ required:+ - id+ - name+ - permalink+ - position+ - depth+ - children_count+ - created_at+ - updated_at+ - taxonomy_id+ - description+ - description_html+ - is_root+ - is_child+ - is_leaf+ - lft+ - rgt+ AdminTaxonomy:+ type: object+ properties:+ id:+ type: string+ name:+ type: string+ position:+ type: number+ created_at:+ type: string+ updated_at:+ type: string+ root_id:+ type: string+ nullable: true+ root:+ "$ref": "#/components/schemas/StoreTaxon"+ taxons:+ type: array+ items:+ "$ref": "#/components/schemas/StoreTaxon"+ metafields:+ type: array+ items:+ "$ref": "#/components/schemas/AdminMetafield"+ x-typelizer: true+ required:+ - id+ - name+ - position+ - created_at+ - updated_atAdminUser:type: objectproperties:@@ -2716,9 +2861,6 @@ components:sku:type: stringnullable: true- barcode:- type: string- nullable: trueis_master:type: booleanoptions_text:@@ -2731,6 +2873,9 @@ components:type: stringupdated_at:type: string+ thumbnail:+ type: string+ nullable: truepurchasable:type: booleanin_stock:@@ -2750,20 +2895,9 @@ components:type: numbernullable: trueprice:- type: number- nullable: true- price_in_cents:- type: number- nullable: true- display_price:- type: string- nullable: true- compare_at_price:- type: number- nullable: true- display_compare_at_price:- type: string- nullable: true+ "$ref": "#/components/schemas/StorePrice"+ original_price:+ "$ref": "#/components/schemas/StorePrice"images:type: arrayitems:@@ -2772,6 +2906,10 @@ components:type: arrayitems:"$ref": "#/components/schemas/StoreOptionValue"+ metafields:+ type: array+ items:+ "$ref": "#/components/schemas/AdminMetafield"position:type: numbertax_category_id:@@ -2789,6 +2927,10 @@ components:total_on_hand:type: numbernullable: true+ prices:+ type: array+ items:+ "$ref": "#/components/schemas/AdminPrice"x-typelizer: truerequired:- id@@ -2802,6 +2944,8 @@ components:- purchasable- in_stock- backorderable+ - price+ - original_price- option_values- positionStoreBase:@@ -2828,11 +2972,9 @@ components:default_currency:type: stringnullable: true- description: Default currency code for this country (e.g., "USD", "EUR")default_locale:type: stringnullable: true- description: Default locale/language for this country (e.g., "en", "de")states:type: arrayitems:@@ -2844,6 +2986,32 @@ components:- name- states_required- zipcode_required+ StoreCreditCard:+ type: object+ properties:+ id:+ type: string+ cc_type:+ type: string+ last_digits:+ type: string+ month:+ type: number+ year:+ type: number+ name:+ type: string+ nullable: true+ default:+ type: boolean+ x-typelizer: true+ required:+ - id+ - cc_type+ - last_digits+ - month+ - year+ - defaultStoreDigitalLink:type: objectproperties:@@ -2980,10 +3148,9 @@ components:compare_at_amount:type: stringnullable: true- images:- type: array- items:- "$ref": "#/components/schemas/StoreImage"+ thumbnail_url:+ type: string+ nullable: trueoption_values:type: arrayitems:@@ -3014,8 +3181,27 @@ components:- display_discounted_amount- created_at- updated_at- - images- option_values+ StoreMetafield:+ type: object+ properties:+ id:+ type: string+ name:+ type: string+ type:+ type: string+ key:+ type: string+ value:+ type: object+ x-typelizer: true+ required:+ - id+ - name+ - type+ - key+ - valueStoreOptionType:type: objectproperties:@@ -3256,41 +3442,36 @@ components:- payment_methodStorePrice:type: object- description: A resolved/calculated price object. Contains the price amount, formatted display string, and optional compare_at pricing for sales.properties:+ id:+ type: stringamount:- type: number+ type: stringnullable: true- description: The price amount as a decimal numberamount_in_cents:- type: integer+ type: numbernullable: true- description: The price amount in cents (integer)- display_amount:+ compare_at_amount:type: stringnullable: true- description: Formatted price string with currency symbol (e.g., "$19.99")- compare_at_amount:+ compare_at_amount_in_cents:type: numbernullable: true- description: Original price before discount (for showing strikethrough)- compare_at_amount_in_cents:- type: integer+ currency:+ type: stringnullable: true- description: Original price in cents before discount- display_compare_at_amount:+ display_amount:type: stringnullable: true- description: Formatted original price string- currency:+ display_compare_at_amount:type: stringnullable: true- description: ISO 4217 currency code (e.g., "USD", "EUR")price_list_id:type: stringnullable: true- description: ID of the price list if one was appliedx-typelizer: true+ required:+ - idStoreProduct:type: objectproperties:@@ -3303,12 +3484,6 @@ components:nullable: trueslug:type: string- sku:- type: string- nullable: true- barcode:- type: string- nullable: truemeta_description:type: stringnullable: true@@ -3332,16 +3507,19 @@ components:type: booleanavailable:type: boolean- price:- "$ref": "#/components/schemas/StorePrice"- description: Current calculated price (may include price list resolution)- original_price:- "$ref": "#/components/schemas/StorePrice"- description: Base price without price list resolution (for showing strikethrough)+ default_variant_id:+ type: string+ thumbnail_url:+ type: string+ nullable: truetags:type: arrayitems:type: string+ price:+ "$ref": "#/components/schemas/StorePrice"+ original_price:+ "$ref": "#/components/schemas/StorePrice"images:type: arrayitems:@@ -3362,6 +3540,10 @@ components:type: arrayitems:"$ref": "#/components/schemas/StoreTaxon"+ metafields:+ type: array+ items:+ "$ref": "#/components/schemas/StoreMetafield"x-typelizer: truerequired:- id@@ -3374,9 +3556,10 @@ components:- in_stock- backorderable- available+ - default_variant_id+ - tags- price- original_price- - tagsStoreShipment:type: objectproperties:@@ -3548,6 +3731,9 @@ components:type: stringupdated_at:type: string+ default_country_iso:+ type: string+ nullable: truesupported_currencies:type: arrayitems:@@ -3565,10 +3751,6 @@ components:type: arrayitems:type: string- default_country_iso:- type: string- nullable: true- description: ISO 3166-1 alpha-2 code of the store's default country (e.g., "US", "DE")payment_methods:type: arrayitems:@@ -3598,10 +3780,6 @@ components:type: stringposition:type: number- lft:- type: number- rgt:- type: numberdepth:type: numbermeta_title:@@ -3646,14 +3824,20 @@ components:type: arrayitems:"$ref": "#/components/schemas/StoreTaxon"+ ancestors:+ type: array+ items:+ "$ref": "#/components/schemas/StoreTaxon"+ metafields:+ type: array+ items:+ "$ref": "#/components/schemas/StoreMetafield"x-typelizer: truerequired:- id- name- permalink- position- - lft- - rgt- depth- children_count- created_at@@ -3677,12 +3861,19 @@ components:type: stringupdated_at:type: string+ root_id:+ type: string+ nullable: trueroot:"$ref": "#/components/schemas/StoreTaxon"taxons:type: arrayitems:"$ref": "#/components/schemas/StoreTaxon"+ metafields:+ type: array+ items:+ "$ref": "#/components/schemas/StoreMetafield"x-typelizer: truerequired:- id@@ -3736,9 +3927,6 @@ components:sku:type: stringnullable: true- barcode:- type: string- nullable: trueis_master:type: booleanoptions_text:@@ -3751,6 +3939,9 @@ components:type: stringupdated_at:type: string+ thumbnail:+ type: string+ nullable: truepurchasable:type: booleanin_stock:@@ -3771,10 +3962,8 @@ components:nullable: trueprice:"$ref": "#/components/schemas/StorePrice"- description: Current calculated price (may include price list resolution)original_price:"$ref": "#/components/schemas/StorePrice"- description: Base price without price list resolution (for showing strikethrough)images:type: arrayitems:@@ -3783,6 +3972,10 @@ components:type: arrayitems:"$ref": "#/components/schemas/StoreOptionValue"+ metafields:+ type: array+ items:+ "$ref": "#/components/schemas/StoreMetafield"x-typelizer: truerequired:- iddiff --git a/sdk/src/client.ts b/sdk/src/client.tsindex 13cc7bb662..63e270a8f9 100644--- a/sdk/src/client.ts+++ b/sdk/src/client.ts@@ -167,7 +167,7 @@ export class SpreeClient {* Register a new customer account*/register: (params: RegisterParams): Promise<AuthTokens> =>- this.request<AuthTokens>('POST', '/auth/register', { body: { user: params } }),+ this.request<AuthTokens>('POST', '/auth/register', { body: params }),/*** Refresh access token (requires valid Bearer token)@@ -401,12 +401,12 @@ export class SpreeClient {*/update: (idOrNumber: string,- order: UpdateOrderParams,+ params: UpdateOrderParams,options?: RequestOptions): Promise<StoreOrder> =>this.request<StoreOrder>('PATCH', `/orders/${idOrNumber}`, {...options,- body: { order },+ body: params,}),/**@@ -555,12 +555,12 @@ export class SpreeClient {*/apply: (orderId: string,- couponCode: string,+ code: string,options?: RequestOptions): Promise<StoreOrder> =>this.request<StoreOrder>('POST', `/orders/${orderId}/coupon_codes`, {...options,- body: { coupon_code: { coupon_code: couponCode } },+ body: { code },}),/**@@ -608,7 +608,7 @@ export class SpreeClient {this.request<StoreShipment>('PATCH',`/orders/${orderId}/shipments/${shipmentId}`,- { ...options, body: { shipment: params } }+ { ...options, body: params }),},};@@ -633,7 +633,7 @@ export class SpreeClient {): Promise<StoreUser> =>this.request<StoreUser>('PATCH', '/customer', {...options,- body: { user: params },+ body: params,}),/**@@ -663,12 +663,12 @@ export class SpreeClient {* Create an address*/create: (- address: AddressParams,+ params: AddressParams,options?: RequestOptions): Promise<StoreAddress> =>this.request<StoreAddress>('POST', '/customer/addresses', {...options,- body: { address },+ body: params,}),/**@@ -676,12 +676,12 @@ export class SpreeClient {*/update: (id: string,- address: Partial<AddressParams>,+ params: Partial<AddressParams>,options?: RequestOptions): Promise<StoreAddress> =>this.request<StoreAddress>('PATCH', `/customer/addresses/${id}`, {...options,- body: { address },+ body: params,}),/**@@ -756,12 +756,12 @@ export class SpreeClient {* Create a wishlist*/create: (- wishlist: { name: string; is_private?: boolean; is_default?: boolean },+ params: { name: string; is_private?: boolean; is_default?: boolean },options?: RequestOptions): Promise<StoreWishlist> =>this.request<StoreWishlist>('POST', '/wishlists', {...options,- body: { wishlist },+ body: params,}),/**@@ -769,12 +769,12 @@ export class SpreeClient {*/update: (id: string,- wishlist: { name?: string; is_private?: boolean; is_default?: boolean },+ params: { name?: string; is_private?: boolean; is_default?: boolean },options?: RequestOptions): Promise<StoreWishlist> =>this.request<StoreWishlist>('PATCH', `/wishlists/${id}`, {...options,- body: { wishlist },+ body: params,}),/**diff --git a/sdk/src/types/index.ts b/sdk/src/types/index.tsindex ece03c4160..d83f6d6545 100644--- a/sdk/src/types/index.ts+++ b/sdk/src/types/index.ts@@ -103,9 +103,16 @@ export interface AddressParams {export interface UpdateOrderParams {email?: string;+ currency?: string;special_instructions?: string;- bill_address_attributes?: AddressParams;- ship_address_attributes?: AddressParams;+ /** Existing address ID to use */+ bill_address_id?: string;+ /** Existing address ID to use */+ ship_address_id?: string;+ /** New billing address */+ bill_address?: AddressParams;+ /** New shipping address */+ ship_address?: AddressParams;}// Product Filters types