Class: ThePlaidApi::PaymentInitiationRecipient

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/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, additional_properties: nil) ⇒ PaymentInitiationRecipient

Returns a new instance of PaymentInitiationRecipient.



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/the_plaid_api/models/payment_initiation_recipient.rb', line 64

def initialize(recipient_id:, name:, address: SKIP, iban: SKIP, bacs: 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
  @additional_properties = additional_properties
end

Instance Attribute Details

#addressPaymentInitiationAddress

The optional address of the payment recipient’s bank account. Required by most institutions outside of the UK.



23
24
25
# File 'lib/the_plaid_api/models/payment_initiation_recipient.rb', line 23

def address
  @address
end

#bacsRecipientBacsNullable

An object containing a BACS account number and sort code. If an IBAN is not provided or if this recipient needs to accept domestic GBP-denominated payments, BACS data is required.



33
34
35
# File 'lib/the_plaid_api/models/payment_initiation_recipient.rb', line 33

def bacs
  @bacs
end

#ibanString

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

Returns:

  • (String)


27
28
29
# File 'lib/the_plaid_api/models/payment_initiation_recipient.rb', line 27

def iban
  @iban
end

#nameString

The name of the recipient.

Returns:

  • (String)


18
19
20
# File 'lib/the_plaid_api/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/the_plaid_api/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.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/the_plaid_api/models/payment_initiation_recipient.rb', line 78

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']

  # 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,
                                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
43
44
# File 'lib/the_plaid_api/models/payment_initiation_recipient.rb', line 36

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
end

.nullablesObject

An array for nullable fields



56
57
58
59
60
61
62
# File 'lib/the_plaid_api/models/payment_initiation_recipient.rb', line 56

def self.nullables
  %w[
    address
    iban
    bacs
  ]
end

.optionalsObject

An array for optional fields



47
48
49
50
51
52
53
# File 'lib/the_plaid_api/models/payment_initiation_recipient.rb', line 47

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



112
113
114
115
116
117
# File 'lib/the_plaid_api/models/payment_initiation_recipient.rb', line 112

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},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



105
106
107
108
109
# File 'lib/the_plaid_api/models/payment_initiation_recipient.rb', line 105

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