Sha256: 75a2222160b281363589057422c025cf8dfbcce7ba266769a72761aa49413d8b

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

module Spree
  module Api
    module V2
      module Storefront
        module OrderConcern
          private

          def render_order(result)
            if result.success?
              render_serialized_payload { serialized_current_order }
            else
              render_error_payload(result.error)
            end
          end

          def ensure_order
            raise ActiveRecord::RecordNotFound if spree_current_order.nil?
          end

          def order_token
            request.headers['X-Spree-Order-Token'] || params[:order_token]
          end

          def spree_current_order
            @spree_current_order ||= find_spree_current_order
          end

          def find_spree_current_order
            Spree::Api::Dependencies.storefront_current_order_finder.constantize.new.execute(
              store: current_store,
              user: spree_current_user,
              token: order_token,
              currency: current_currency
            )
          end

          def supported_currencies
            current_store.supported_currencies_list
          end

          def serialize_order(order)
            resource_serializer.new(order.reload, include: resource_includes, fields: sparse_fields).serializable_hash
          end

          def serialized_current_order
            serialize_order(spree_current_order)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_api-4.2.0.rc4 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.2.0.rc3 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.2.0.rc2 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.2.0.rc1 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.2.0.beta app/controllers/concerns/spree/api/v2/storefront/order_concern.rb