Class: Moip::Invoice
- Includes:
- HTTParty, Header
- Defined in:
- lib/moip/models/invoice.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#creation_date ⇒ Object
Returns the value of attribute creation_date.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#id ⇒ Object
Returns the value of attribute id.
-
#items ⇒ Object
Returns the value of attribute items.
-
#occurrence ⇒ Object
Returns the value of attribute occurrence.
-
#plan ⇒ Object
Returns the value of attribute plan.
-
#status ⇒ Object
Returns the value of attribute status.
-
#subscription_code ⇒ Object
Returns the value of attribute subscription_code.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #find ⇒ Object
- #full_status ⇒ Object
- #invoices ⇒ Object
- #invoices=(hash) ⇒ Object
- #load ⇒ Object
- #payments ⇒ Object
- #retry ⇒ Object
Methods included from Header
#auth, #base_url, #default_header
Methods inherited from Model
build, #set_parameters, #to_json, #validate_response
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
6 7 8 |
# File 'lib/moip/models/invoice.rb', line 6 def amount @amount end |
#creation_date ⇒ Object
Returns the value of attribute creation_date.
6 7 8 |
# File 'lib/moip/models/invoice.rb', line 6 def creation_date @creation_date end |
#customer ⇒ Object
Returns the value of attribute customer.
6 7 8 |
# File 'lib/moip/models/invoice.rb', line 6 def customer @customer end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/moip/models/invoice.rb', line 6 def id @id end |
#items ⇒ Object
Returns the value of attribute items.
6 7 8 |
# File 'lib/moip/models/invoice.rb', line 6 def items @items end |
#occurrence ⇒ Object
Returns the value of attribute occurrence.
6 7 8 |
# File 'lib/moip/models/invoice.rb', line 6 def occurrence @occurrence end |
#plan ⇒ Object
Returns the value of attribute plan.
6 7 8 |
# File 'lib/moip/models/invoice.rb', line 6 def plan @plan end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/moip/models/invoice.rb', line 6 def status @status end |
#subscription_code ⇒ Object
Returns the value of attribute subscription_code.
6 7 8 |
# File 'lib/moip/models/invoice.rb', line 6 def subscription_code @subscription_code end |
Class Method Details
.retry(id) ⇒ Object
66 67 68 |
# File 'lib/moip/models/invoice.rb', line 66 def self.retry id response = self.class.post(base_url(:payments, :code => id, :status => "retry"), default_header).parsed_response end |
Instance Method Details
#attributes ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/moip/models/invoice.rb', line 9 def attributes { "id" => id, "amount" => amount, "subscription_code" => subscription_code, "occurrence" => occurrence, "status" => status, "items" => items, "plan" => plan, "customer" => customer, "creation_date" => creation_date } end |
#find ⇒ Object
53 54 55 56 |
# File 'lib/moip/models/invoice.rb', line 53 def find response = self.class.get(base_url(:invoices, :code => self.id), default_header).parsed_response self.set_parameters response unless response.nil? end |
#full_status ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/moip/models/invoice.rb', line 33 def full_status status = case self.status['code'] when 1 then "Em aberto" # A fatura foi gerada mas ainda não foi paga pelo assinante. when 2 then "Aguardando Confirmação" # A fatura foi paga pelo assinante, mas o pagamento está em processo de análise de risco. when 3 then "Pago" # A fatura foi paga pelo assinante e confirmada. when 4 then "Não Pago" # O assinante tentou pagar a fatura, mas o pagamento foi negado pelo banco emissor do cartão de crédito ou a análise de risco detectou algum problema. Veja os motivos possíveis. when 5 then "Atrasada" # O pagamento da fatura foi cancelado e serão feitas novas tentativas de cobrança de acordo com a configuração de retentativa automática. end status end |
#invoices ⇒ Object
44 45 46 |
# File 'lib/moip/models/invoice.rb', line 44 def invoices @invoices ||= self.invoices=(self.load) end |
#invoices=(hash) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/moip/models/invoice.rb', line 23 def invoices= hash @invoices = [] hash.each do |e| invoice = Moip::Invoice.new invoice.set_parameters e @invoices << invoice end @invoices end |
#load ⇒ Object
48 49 50 51 |
# File 'lib/moip/models/invoice.rb', line 48 def load list = self.class.get(base_url(:subscriptions, :code => self.subscription_code, :status => "invoices"), default_header).parsed_response self.invoices = list["invoices"] end |
#payments ⇒ Object
58 59 60 |
# File 'lib/moip/models/invoice.rb', line 58 def payments @payments ||= Moip::Payment.build(:invoice => self.id).payments end |
#retry ⇒ Object
62 63 64 |
# File 'lib/moip/models/invoice.rb', line 62 def retry response = self.class.post(base_url(:invoices, :code => self.id, :status => "retry"), default_header).parsed_response end |