lib/tophatter_merchant/variation.rb in tophatter-merchant-1.2.2 vs lib/tophatter_merchant/variation.rb in tophatter-merchant-1.3.0
- old
+ new
@@ -1,31 +1,31 @@
module TophatterMerchant
class Variation < Resource
- attr_accessor :product_identifier, :identifier,
- :size, :color, :quantity,
- :created_at, :disabled_at, :deleted_at
+ # http://merchant-api.tophatter.com/docs/variation-schema
+ attr_accessor :product_identifier,
+ :identifier,
+ :internal_id,
+ :size,
+ :color,
+ :quantity,
+ :created_at,
+ :disabled_at,
+ :deleted_at
- def id
- created_at.present? ? identifier : nil
- end
-
class << self
- # ap TophatterMerchant::Variation.schema
- def schema
- get(url: "#{path}/schema.json")
- end
-
- # ap TophatterMerchant::Variation.retrieve('FOOBAR-R').to_h
+ # 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
- # ap Variation.create(product_identifier: '6631A', identifier: '6631A-GRAY', color: 'Gray', quantity: 33).to_h
+ # http://merchant-api.tophatter.com/docs/variation-create
def create(params)
Variation.new post(url: "#{path}.json", params: params)
end
- # ap TophatterMerchant::Variation.update('FOOBAR-R', quantity: 100).to_h
+ # 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