Sha256: cd0e99b02681440cecabeacde7d4c71297bb8d4f5db9856e1e3a1da9b0f227f7

Contents?: true

Size: 1.29 KB

Versions: 32

Compression:

Stored size: 1.29 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: spree_current_store,
              user: spree_current_user,
              token: order_token,
              currency: current_currency
            )
          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

32 entries across 32 versions & 1 rubygems

Version Path
spree_api-4.0.9 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.0.8 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-3.7.14.1 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.0.7.1 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.0.7 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-3.7.14 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.0.6 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-3.7.13 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.0.5 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-3.7.12 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.0.4 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-3.7.11 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-3.7.10 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.0.3 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-3.7.9 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.0.2 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-3.7.8 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.0.1 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-3.7.7 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.0.0 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb