Class: MyMoip::PaymentMethods

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/mymoip/payment_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ PaymentMethods

Returns a new instance of PaymentMethods.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mymoip/payment_methods.rb', line 11

def initialize(attrs = {})
  self.payment_slip = true
  self.credit_card  = true
  self.debit        = true
  self.debit_card   = true
  self.financing    = true
  self.moip_wallet  = true

  attrs.each do |attr, value|
    public_send(:"#{attr}=", value)
  end
end

Instance Attribute Details

#credit_cardObject

Returns the value of attribute credit_card.



5
6
7
# File 'lib/mymoip/payment_methods.rb', line 5

def credit_card
  @credit_card
end

#debitObject

Returns the value of attribute debit.



5
6
7
# File 'lib/mymoip/payment_methods.rb', line 5

def debit
  @debit
end

#debit_cardObject

Returns the value of attribute debit_card.



5
6
7
# File 'lib/mymoip/payment_methods.rb', line 5

def debit_card
  @debit_card
end

#financingObject

Returns the value of attribute financing.



5
6
7
# File 'lib/mymoip/payment_methods.rb', line 5

def financing
  @financing
end

#moip_walletObject

Returns the value of attribute moip_wallet.



5
6
7
# File 'lib/mymoip/payment_methods.rb', line 5

def moip_wallet
  @moip_wallet
end

#payment_slipObject

Returns the value of attribute payment_slip.



5
6
7
# File 'lib/mymoip/payment_methods.rb', line 5

def payment_slip
  @payment_slip
end

Instance Method Details

#to_xml(root = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mymoip/payment_methods.rb', line 24

def to_xml(root = nil)
  if root.nil?
    xml = ""
    root ||= Builder::XmlMarkup.new(target: xml)
  end

  if not using_all?
    root.FormaPagamento('BoletoBancario')        if payment_slip
    root.FormaPagamento('CartaoDeCredito')       if credit_card
    root.FormaPagamento('DebitoBancario')        if debit
    root.FormaPagamento('CartaoDeDebito')        if debit_card
    root.FormaPagamento('FinanciamentoBancario') if financing
    root.FormaPagamento('CarteiraMoIP')          if moip_wallet
  end

  xml
end

#using_all?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/mymoip/payment_methods.rb', line 42

def using_all?
  payment_slip and credit_card and debit and debit_card and financing and moip_wallet
end