Class: Moip::Payment

Inherits:
Model
  • Object
show all
Includes:
HTTParty, Header
Defined in:
lib/moip/models/payment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Header

#auth, #base_url, #default_header

Methods inherited from Model

build, #set_parameters, #to_json, #validate_response

Instance Attribute Details

#creation_dateObject

Returns the value of attribute creation_date.



5
6
7
# File 'lib/moip/models/payment.rb', line 5

def creation_date
  @creation_date
end

#customer_codeObject

Returns the value of attribute customer_code.



5
6
7
# File 'lib/moip/models/payment.rb', line 5

def customer_code
  @customer_code
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/moip/models/payment.rb', line 5

def id
  @id
end

#invoiceObject

Returns the value of attribute invoice.



5
6
7
# File 'lib/moip/models/payment.rb', line 5

def invoice
  @invoice
end

#moip_idObject

Returns the value of attribute moip_id.



5
6
7
# File 'lib/moip/models/payment.rb', line 5

def moip_id
  @moip_id
end

#payment_methodObject

Returns the value of attribute payment_method.



5
6
7
# File 'lib/moip/models/payment.rb', line 5

def payment_method
  @payment_method
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/moip/models/payment.rb', line 5

def status
  @status
end

#subscription_codeObject

Returns the value of attribute subscription_code.



5
6
7
# File 'lib/moip/models/payment.rb', line 5

def subscription_code
  @subscription_code
end

Instance Method Details

#attributesObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/moip/models/payment.rb', line 9

def attributes
	{ 
		"id" => id,
		"moip_id" => moip_id,
		"status" => status,
		"subscription_code" => subscription_code,
		"customer_code" => customer_code,
		"invoice" => invoice,
		"payment_method" => payment_method,
		"creation_date" => creation_date
	}
end

#findObject



41
42
43
44
# File 'lib/moip/models/payment.rb', line 41

def find
	response = self.class.get(base_url(:payments, :code => self.id), default_header).parsed_response
	self.set_parameters response unless response.nil?
end

#loadObject



36
37
38
39
# File 'lib/moip/models/payment.rb', line 36

def load
	list = self.class.get(base_url(:invoices, :code => self.invoice, :status => "payments"), default_header).parsed_response
	self.payments = list["payments"]
end

#paymentsObject



32
33
34
# File 'lib/moip/models/payment.rb', line 32

def payments
	@payments ||= self.payments = self.load
end

#payments=(hash) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/moip/models/payment.rb', line 22

def payments= hash
	@payments = []
	hash.each do |e|
		payment = Moip::Payment.new
		payment.set_parameters e
		@payments << payment
	end
	@payments
end