Class: Recharge::Charge

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = '') ⇒ Charge

Returns a new instance of Charge.



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

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

Class Method Details

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



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

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

.find(id, apiKey = nil) ⇒ Object



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

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

.find_all(apiKey = nil) ⇒ Object



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

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

Instance Method Details

#destroy(apiKey = nil) ⇒ Object



41
42
43
# File 'lib/recharge/charge.rb', line 41

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

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



37
38
39
40
# File 'lib/recharge/charge.rb', line 37

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