Class: Recharge::Product

Inherits:
Object
  • Object
show all
Includes:
HappyMapper
Defined in:
lib/recharge/product.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = '') ⇒ Product

Returns a new instance of Product.



14
15
16
# File 'lib/recharge/product.rb', line 14

def initialize(id='')
  @id = id
end

Class Method Details

.create(attributes = {}, apiKey = nil) ⇒ Object



25
26
27
28
# File 'lib/recharge/product.rb', line 25

def self.create (attributes = {}, apiKey=nil)
  responseXML = Recharge::Base.post('products', attributes, apiKey)
  parse(responseXML.to_s)
end

.find(id, apiKey = nil) ⇒ Object



21
22
23
24
# File 'lib/recharge/product.rb', line 21

def self.find (id, apiKey=nil)
  responseXML = Recharge::Base.get('products/'+id, apiKey)
  parse(responseXML.to_s)
end

.find_all(apiKey = nil) ⇒ Object



17
18
19
20
# File 'lib/recharge/product.rb', line 17

def self.find_all (apiKey=nil)
  responseXML = Recharge::Base.get('products', apiKey)
  parse(responseXML.to_s)
end

Instance Method Details

#destroy(apiKey = nil) ⇒ Object



33
34
35
# File 'lib/recharge/product.rb', line 33

def destroy (apiKey=nil)
  responseXML = Recharge::Base.delete('products/'+self.id, apiKey)
end

#update(attributes = {}, apiKey = nil) ⇒ Object



29
30
31
32
# File 'lib/recharge/product.rb', line 29

def update (attributes = {}, apiKey=nil)
  responseXML = Recharge::Base.post('products/'+self.id, attributes, apiKey)
  Product.parse(responseXML.to_s)
end