Class: PaymentsApi::Beneficiary

Inherits:
BaseModel show all
Defined in:
lib/payments_api/models/beneficiary.rb

Overview

Beneficiary Information Object

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(name = nil, address = nil, email = nil, phone_number = nil) ⇒ Beneficiary

Returns a new instance of Beneficiary.



35
36
37
38
39
40
41
42
43
# File 'lib/payments_api/models/beneficiary.rb', line 35

def initialize(name = nil,
               address = nil,
               email = nil,
               phone_number = nil)
  @name = name
  @address = address
  @email = email
  @phone_number = phone_number
end

Instance Attribute Details

#addressAddress

Address Information

Returns:



15
16
17
# File 'lib/payments_api/models/beneficiary.rb', line 15

def address
  @address
end

#emailString

Beneficiary Email Address

Returns:

  • (String)


19
20
21
# File 'lib/payments_api/models/beneficiary.rb', line 19

def email
  @email
end

#nameString

Beneficiary Name

Returns:

  • (String)


11
12
13
# File 'lib/payments_api/models/beneficiary.rb', line 11

def name
  @name
end

#phone_numberString

Beneficiary Phone Number

Returns:

  • (String)


23
24
25
# File 'lib/payments_api/models/beneficiary.rb', line 23

def phone_number
  @phone_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/payments_api/models/beneficiary.rb', line 46

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash['name']
  address = Address.from_hash(hash['address']) if hash['address']
  email = hash['email']
  phone_number = hash['phoneNumber']

  # Create object from extracted values.
  Beneficiary.new(name,
                  address,
                  email,
                  phone_number)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
33
# File 'lib/payments_api/models/beneficiary.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['address'] = 'address'
  @_hash['email'] = 'email'
  @_hash['phone_number'] = 'phoneNumber'
  @_hash
end