Class: Pagseguro::Charge::Holder

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

Overview

Credit card data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Holder

Returns a new instance of Holder.



16
17
18
19
20
21
# File 'lib/pagseguro/charge/holder.rb', line 16

def initialize(args = {})
  @name = args[:name]
  @tax_id = args[:tax_id]
  @email = args[:email]
  @address = args[:address]
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



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

def address
  @address
end

#brandString

Credit card brand

Returns:

  • (String)

    the current value of brand



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

def brand
  @brand
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#exp_monthinteger

Credit card expiration month

Returns:

  • (integer)

    the current value of exp_month



10
11
12
# File 'lib/pagseguro/charge/holder.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/holder.rb', line 10

def exp_year
  @exp_year
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#numberLong

Credit card number

Returns:

  • (Long)

    the current value of number



10
11
12
# File 'lib/pagseguro/charge/holder.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/holder.rb', line 10

def security_code
  @security_code
end

#tax_idObject

Returns the value of attribute tax_id.



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

def tax_id
  @tax_id
end

Class Method Details

.fill_from_json(data) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/pagseguro/charge/holder.rb', line 29

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

  holder = new
  holder.name = data["name"]
  holder.tax_id = data["tax_id"]
  holder.email = data["email"]
  holder.address = Address.fill_from_json(data["address"])
  holder
end

Instance Method Details

#as_json(options = {}) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/pagseguro/charge/holder.rb', line 40

def as_json(options={})
  {
    name: @name,
    tax_id: @tax_id,
    email: @email,
    address: @address
  }
end

#to_json(*options) ⇒ Object



23
24
25
26
27
# File 'lib/pagseguro/charge/holder.rb', line 23

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