Class: FetchAPI::Item

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

basic_auth, find

Constructor Details

#initialize(id_or_attributes) ⇒ Item

Returns a new instance of Item.



5
6
7
8
9
10
11
12
13
# File 'lib/fetchapi/item.rb', line 5

def initialize(id_or_attributes)
  case id_or_attributes
  when Integer, String
    @attributes = get("/#{self.class.pluralized_class_name}/#{id_or_attributes.to_s}")
    @attributes = @attributes[self.class.singularized_class_name]
  when Hash
    @attributes = id_or_attributes
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class FetchAPI::Base

Instance Attribute Details

#attributes ⇒ Object

Returns the value of attribute attributes.



3
4
5
# File 'lib/fetchapi/item.rb', line 3

def attributes
  @attributes
end

Class Method Details

.create(options) ⇒ Object

--

Class Methods ###############



18
19
20
# File 'lib/fetchapi/item.rb', line 18

def self.create(options)
  execute(:post, "/items/create", :item => options)
end

Instance Method Details

#destroy ⇒ Object

--

Instance Methods ###############



26
27
28
# File 'lib/fetchapi/item.rb', line 26

def destroy
  delete("/items/#{sku}/delete")
end

#update(options) ⇒ Object



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

def update(options)
  put("/items/#{sku}", :item => options)
end