Sha256: 9527293316b36e8ebe8a0bf9dfaac31491accb593882f4927389d12233dbfdb2

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 KB

Contents

module Spree
  module Api
    module V2
      module Platform
        class VariantSerializer < BaseSerializer
          include ::Spree::Api::V2::ResourceSerializerConcern
          include ::Spree::Api::V2::DisplayMoneyHelper

          attributes :name, :options_text, :total_on_hand

          attribute :purchasable do |product|
            product.purchasable?
          end

          attribute :in_stock do |product|
            product.in_stock?
          end

          attribute :backorderable do |product|
            product.backorderable?
          end

          attribute :available do |product|
            product.available?
          end

          attribute :currency do |_product, params|
            params[:currency]
          end

          attribute :price do |object, params|
            price(object, params[:currency])
          end

          attribute :display_price do |object, params|
            display_price(object, params[:currency])
          end

          attribute :compare_at_price do |object, params|
            compare_at_price(object, params[:currency])
          end

          attribute :display_compare_at_price do |object, params|
            display_compare_at_price(object, params[:currency])
          end

          belongs_to :product
          belongs_to :tax_category
          has_many :images
          has_many :option_values
          has_many :stock_items
          has_many :stock_locations
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spree_api-4.3.3 app/serializers/spree/api/v2/platform/variant_serializer.rb
spree_api-4.3.2 app/serializers/spree/api/v2/platform/variant_serializer.rb
spree_api-4.3.1 app/serializers/spree/api/v2/platform/variant_serializer.rb
spree_api-4.3.0 app/serializers/spree/api/v2/platform/variant_serializer.rb
spree_api-4.3.0.rc3 app/serializers/spree/api/v2/platform/variant_serializer.rb
spree_api-4.3.0.rc2 app/serializers/spree/api/v2/platform/variant_serializer.rb
spree_api-4.3.0.rc1 app/serializers/spree/api/v2/platform/variant_serializer.rb