Class: TophatterMerchant::Variation

Inherits:
Resource
  • Object
show all
Defined in:
lib/tophatter_merchant/variation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

attr_accessor, #attributes, attributes, #attributes=, #initialize, #persisted?, #to_h

Constructor Details

This class inherits a constructor from TophatterMerchant::Resource

Instance Attribute Details

#colorObject

Returns the value of attribute color.



3
4
5
# File 'lib/tophatter_merchant/variation.rb', line 3

def color
  @color
end

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/tophatter_merchant/variation.rb', line 3

def created_at
  @created_at
end

#deleted_atObject

Returns the value of attribute deleted_at.



3
4
5
# File 'lib/tophatter_merchant/variation.rb', line 3

def deleted_at
  @deleted_at
end

#disabled_atObject

Returns the value of attribute disabled_at.



3
4
5
# File 'lib/tophatter_merchant/variation.rb', line 3

def disabled_at
  @disabled_at
end

#identifierObject

Returns the value of attribute identifier.



3
4
5
# File 'lib/tophatter_merchant/variation.rb', line 3

def identifier
  @identifier
end

#product_identifierObject

Returns the value of attribute product_identifier.



3
4
5
# File 'lib/tophatter_merchant/variation.rb', line 3

def product_identifier
  @product_identifier
end

#quantityObject

Returns the value of attribute quantity.



3
4
5
# File 'lib/tophatter_merchant/variation.rb', line 3

def quantity
  @quantity
end

#sizeObject

Returns the value of attribute size.



3
4
5
# File 'lib/tophatter_merchant/variation.rb', line 3

def size
  @size
end

Class Method Details

.create(params) ⇒ Object

ap Variation.create(product_identifier: ‘6631A’, identifier: ‘6631A-GRAY’, color: ‘Gray’, quantity: 33).to_h



23
24
25
# File 'lib/tophatter_merchant/variation.rb', line 23

def create(params)
  Variation.new post(url: "#{path}.json", params: params)
end

.retrieve(identifier) ⇒ Object

ap TophatterMerchant::Variation.retrieve(‘FOOBAR-R’).to_h



18
19
20
# File 'lib/tophatter_merchant/variation.rb', line 18

def retrieve(identifier)
  Variation.new get(url: "#{path}/retrieve.json", params: { identifier: identifier })
end

.schemaObject

ap TophatterMerchant::Variation.schema



13
14
15
# File 'lib/tophatter_merchant/variation.rb', line 13

def schema
  get(url: "#{path}/schema.json")
end

.update(identifier, data) ⇒ Object

ap TophatterMerchant::Variation.update(‘FOOBAR-R’, quantity: 100).to_h



28
29
30
# File 'lib/tophatter_merchant/variation.rb', line 28

def update(identifier, data)
  Variation.new post(url: "#{path}/update.json", params: data.merge(identifier: identifier))
end

Instance Method Details

#idObject



7
8
9
# File 'lib/tophatter_merchant/variation.rb', line 7

def id
  created_at.present? ? identifier : nil
end