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