class MyMoip::PaymentMethods

Attributes

credit_card[RW]
debit[RW]
debit_card[RW]
financing[RW]
moip_wallet[RW]
payment_slip[RW]

Public Class Methods

new(attrs = {}) click to toggle source
# 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

Public Instance Methods

to_xml(root = nil) click to toggle source
# 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?() click to toggle source
# 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