Class: Plaid::PaymentInitiationRecipient

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/plaid/models/payment_initiation_recipient.rb

Overview

PaymentInitiationRecipient defines a payment initiation recipient

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(recipient_id:, name:, address: SKIP, iban: SKIP, bacs: SKIP, emi_recipient_id: SKIP, additional_properties: nil) ⇒ PaymentInitiationRecipient

Returns a new instance of PaymentInitiationRecipient.



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 71

def initialize(recipient_id:, name:, address: SKIP, iban: SKIP, bacs: SKIP,
               emi_recipient_id: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @recipient_id = recipient_id
  @name = name
  @address = address unless address == SKIP
  @iban = iban unless iban == SKIP
  @bacs = bacs unless bacs == SKIP
  @emi_recipient_id = emi_recipient_id unless emi_recipient_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#addressPaymentInitiationAddress

The optional address of the payment recipient. This object is not currently required to make payments from UK institutions and should not be populated, though may be necessary for future European expansion.



24
25
26
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 24

def address
  @address
end

#bacsRecipientBacsNullable

The International Bank Account Number (IBAN) for the recipient.



32
33
34
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 32

def bacs
  @bacs
end

#emi_recipient_idString

The EMI (E-Money Institution) recipient that this recipient is associated with, if any. This EMI recipient is used as an intermediary account to enable Plaid to reconcile the settlement of funds for Payment Initiation requests.

Returns:

  • (String)


39
40
41
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 39

def emi_recipient_id
  @emi_recipient_id
end

#ibanString

The International Bank Account Number (IBAN) for the recipient.

Returns:

  • (String)


28
29
30
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 28

def iban
  @iban
end

#nameString

The name of the recipient.

Returns:

  • (String)


18
19
20
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 18

def name
  @name
end

#recipient_idString

The ID of the recipient.

Returns:

  • (String)


14
15
16
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 14

def recipient_id
  @recipient_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 86

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  recipient_id = hash.key?('recipient_id') ? hash['recipient_id'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  address = PaymentInitiationAddress.from_hash(hash['address']) if hash['address']
  iban = hash.key?('iban') ? hash['iban'] : SKIP
  bacs = RecipientBacsNullable.from_hash(hash['bacs']) if hash['bacs']
  emi_recipient_id =
    hash.key?('emi_recipient_id') ? hash['emi_recipient_id'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  PaymentInitiationRecipient.new(recipient_id: recipient_id,
                                 name: name,
                                 address: address,
                                 iban: iban,
                                 bacs: bacs,
                                 emi_recipient_id: emi_recipient_id,
                                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



42
43
44
45
46
47
48
49
50
51
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 42

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['recipient_id'] = 'recipient_id'
  @_hash['name'] = 'name'
  @_hash['address'] = 'address'
  @_hash['iban'] = 'iban'
  @_hash['bacs'] = 'bacs'
  @_hash['emi_recipient_id'] = 'emi_recipient_id'
  @_hash
end

.nullablesObject

An array for nullable fields



64
65
66
67
68
69
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 64

def self.nullables
  %w[
    iban
    emi_recipient_id
  ]
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
60
61
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 54

def self.optionals
  %w[
    address
    iban
    bacs
    emi_recipient_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



124
125
126
127
128
129
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 124

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} recipient_id: #{@recipient_id.inspect}, name: #{@name.inspect}, address:"\
  " #{@address.inspect}, iban: #{@iban.inspect}, bacs: #{@bacs.inspect}, emi_recipient_id:"\
  " #{@emi_recipient_id.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



116
117
118
119
120
121
# File 'lib/plaid/models/payment_initiation_recipient.rb', line 116

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} recipient_id: #{@recipient_id}, name: #{@name}, address: #{@address}, iban:"\
  " #{@iban}, bacs: #{@bacs}, emi_recipient_id: #{@emi_recipient_id}, additional_properties:"\
  " #{@additional_properties}>"
end