Sha256: ebb982801dc97f2467308b362f0673996fa759d3b45d4d0b1660fc6f1226d87f

Contents?: true

Size: 1.28 KB

Versions: 21

Compression:

Stored size: 1.28 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 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

21 entries across 21 versions & 1 rubygems

Version Path
spree_api-4.1.15 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.14 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.13.1 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.2.0.rc5 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.13 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.12 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.11 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.10 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.9 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.8 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.7 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.6 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.5 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.4 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.3 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.2 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.1 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.0 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.0.rc3 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb
spree_api-4.1.0.rc2 app/controllers/concerns/spree/api/v2/storefront/order_concern.rb