Sha256: de2f0f13071b1f51e910dc713b839adac7828f970c63433ce6041dbce343d60b

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

module TophatterMerchant
  class Variation < Resource
    # http://merchant-api.tophatter.com/docs/variation-schema
    attr_accessor :product_identifier,
                  :identifier,
                  :internal_id,
                  :size,
                  :color,
                  :quantity,
                  :created_at,
                  :disabled_at,
                  :deleted_at

    class << self
      # http://merchant-api.tophatter.com/docs/variation-retrieve
      # TophatterMerchant::Variation.retrieve('B01J90O7KK')
      def retrieve(identifier)
        Variation.new get(url: "#{path}/retrieve.json", params: { identifier: identifier })
      end

      # http://merchant-api.tophatter.com/docs/variation-create
      def create(params)
        Variation.new post(url: "#{path}.json", params: params)
      end

      # http://merchant-api.tophatter.com/docs/variation-update
      # TophatterMerchant::Variation.update('B01J90O7KK', quantity: 1).quantity
      def update(identifier, data)
        Variation.new post(url: "#{path}/update.json", params: data.merge(identifier: identifier))
      end

      protected

      def path
        super + '/variations'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tophatter-merchant-1.3.3 lib/tophatter_merchant/variation.rb
tophatter-merchant-1.3.2 lib/tophatter_merchant/variation.rb
tophatter-merchant-1.3.1 lib/tophatter_merchant/variation.rb
tophatter-merchant-1.3.0 lib/tophatter_merchant/variation.rb