Class: Pagseguro::Charge::Boleto

Inherits:
Object
  • Object
show all
Defined in:
lib/pagseguro/charge/boleto.rb

Overview

Credit card data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Boleto

Returns a new instance of Boleto.



19
20
21
22
23
# File 'lib/pagseguro/charge/boleto.rb', line 19

def initialize(args = {})
  @due_date = args[:due_date]
  @instruction_lines = args[:instruction_lines]
  @holder = args[:holder]
end

Instance Attribute Details

#barcodeObject

Returns the value of attribute barcode.



11
12
13
# File 'lib/pagseguro/charge/boleto.rb', line 11

def barcode
  @barcode
end

#brandString

Credit card brand

Returns:

  • (String)

    the current value of brand



10
11
12
# File 'lib/pagseguro/charge/boleto.rb', line 10

def brand
  @brand
end

#due_dateObject

Returns the value of attribute due_date.



11
12
13
# File 'lib/pagseguro/charge/boleto.rb', line 11

def due_date
  @due_date
end

#exp_monthinteger

Credit card expiration month

Returns:

  • (integer)

    the current value of exp_month



10
11
12
# File 'lib/pagseguro/charge/boleto.rb', line 10

def exp_month
  @exp_month
end

#exp_yearInteger

Credit card expiration year

Returns:

  • (Integer)

    the current value of exp_year



10
11
12
# File 'lib/pagseguro/charge/boleto.rb', line 10

def exp_year
  @exp_year
end

#formatted_barcodeObject

Returns the value of attribute formatted_barcode.



11
12
13
# File 'lib/pagseguro/charge/boleto.rb', line 11

def formatted_barcode
  @formatted_barcode
end

#holderObject

Returns the value of attribute holder.



11
12
13
# File 'lib/pagseguro/charge/boleto.rb', line 11

def holder
  @holder
end

#idObject

Returns the value of attribute id.



11
12
13
# File 'lib/pagseguro/charge/boleto.rb', line 11

def id
  @id
end

#instruction_linesObject

Returns the value of attribute instruction_lines.



11
12
13
# File 'lib/pagseguro/charge/boleto.rb', line 11

def instruction_lines
  @instruction_lines
end

#numberLong

Credit card number

Returns:

  • (Long)

    the current value of number



10
11
12
# File 'lib/pagseguro/charge/boleto.rb', line 10

def number
  @number
end

#security_codeString

Credit card security_code

Returns:

  • (String)

    the current value of security_code



10
11
12
# File 'lib/pagseguro/charge/boleto.rb', line 10

def security_code
  @security_code
end

Class Method Details

.fill_from_json(data) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pagseguro/charge/boleto.rb', line 31

def self.fill_from_json(data)
  return if data.nil?

  boleto = new
  boleto.due_date = data["due_date"]
  boleto.instruction_lines = InstructionLines.fill_from_json(data["instruction_lines"])
  boleto.holder = Holder.fill_from_json(data["holder"])
  boleto.barcode = data["barcode"]
  boleto.id = data["id"]
  boleto.formatted_barcode = data["formatted_barcode"]
  boleto
end

Instance Method Details

#as_json(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/pagseguro/charge/boleto.rb', line 44

def as_json(options={})
  {
    id: @id,
    due_date: @due_date,
    instruction_lines: @instruction_lines,
    barcode: @barcode,
    formatted_barcode: @formatted_barcode,
    holder: @holder
  }
end

#to_json(*options) ⇒ Object



25
26
27
28
29
# File 'lib/pagseguro/charge/boleto.rb', line 25

def to_json(*options)
  hash = as_json(*options)
  hash.reject! {|k,v| v.nil?}
  hash.to_json(*options)
end