Class: DHL::Ecommerce::Product

Inherits:
Base
  • Object
show all
Includes:
Operations::Find, Operations::List
Defined in:
lib/dhl/ecommerce/product.rb

Constant Summary collapse

TYPES =
{
  domestic: "DomesticUS",
  international: "International"
}
CATEGORIES =
{
  clearance: "Clearance",
  expedited: "Expedited",
  expedited_parcel: "Expedited P",
  ground: "Ground",
  other: "Other Services",
  priority: "Priority",
  standard: "Standard"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Operations::List

included

Methods included from Operations::Find

included

Constructor Details

#initialize(attributes = {}) ⇒ Product

Returns a new instance of Product.



24
25
26
27
28
29
30
31
# File 'lib/dhl/ecommerce/product.rb', line 24

def initialize(attributes = {})
  super attributes

  unless attributes.empty?
    @category = CATEGORIES.key(attributes[:category]) if attributes[:category]
    @type = TYPES.key(attributes[:class]) if attributes[:class]
  end
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



22
23
24
# File 'lib/dhl/ecommerce/product.rb', line 22

def category
  @category
end

#idObject (readonly)

Returns the value of attribute id.



22
23
24
# File 'lib/dhl/ecommerce/product.rb', line 22

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/dhl/ecommerce/product.rb', line 22

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



22
23
24
# File 'lib/dhl/ecommerce/product.rb', line 22

def type
  @type
end