Class: JanioAPI::Item

Inherits:
Base
  • Object
show all
Defined in:
lib/janio_api/resources/item.rb

Constant Summary collapse

VALID_ITEM_CATEGORIES =
["Fashion Accessories", "Fashion Footwear", "Fashion Apparels (Men)", "Fashion Apparels (Women)",
"Fashion Apparels (Babies, Toddlers and Children)", "Fashion Apparel", "Electronics",
"Electronics (Non-Telecommunications)", "Electronics (Telecommunications)", "Lifestyle Products",
"Lifestyle (Health Related)", "Lifestyle (Beauty Related)", "Lifestyle (Home & Living)",
"Lifestyle (Hobbies & Collection)", "Lifestyle (Pantry & Packaged Food & Beverages)", "Others", "Printed Matters"].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, persisted = false) ⇒ Item

Returns a new instance of Item.



22
23
24
25
26
27
28
# File 'lib/janio_api/resources/item.rb', line 22

def initialize(attributes = {}, persisted = false)
  default_attrs = {
    item_desc: nil, item_quantity: nil, item_price_value: nil, item_price_currency: nil, item_category: nil
  }
  attributes = default_attrs.merge(attributes)
  super
end

Class Method Details

.createObject



16
17
18
19
# File 'lib/janio_api/resources/item.rb', line 16

def create
  raise "JanioAPI::Item cannot be created directly, "\
  "please include it in an JanioAPI::Order to create it under a new JanioAPI::Order."
end

.find(*args) ⇒ Object



12
13
14
# File 'lib/janio_api/resources/item.rb', line 12

def find(*args)
  raise "JanioAPI::Item cannot be fetched directly, plesase use JanioAPI::Order to fetch the items under the order."
end

Instance Method Details

#createObject



30
31
32
# File 'lib/janio_api/resources/item.rb', line 30

def create
  self.class.create
end

#updateObject



34
35
36
37
# File 'lib/janio_api/resources/item.rb', line 34

def update
  raise "JanioAPI::Item cannot be updated, only creation is supported and "\
  "please include it in an JanioAPI::Order to create it under a new JanioAPI::Order."
end