Class: Plaid::PaymentInitiationAddress

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

Overview

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.

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(street:, city:, postal_code:, country:, additional_properties: nil) ⇒ PaymentInitiationAddress

Returns a new instance of PaymentInitiationAddress.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/plaid/models/payment_initiation_address.rb', line 51

def initialize(street:, city:, postal_code:, country:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @street = street
  @city = city
  @postal_code = postal_code
  @country = country
  @additional_properties = additional_properties
end

Instance Attribute Details

#cityString

The city where the recipient is located. Maximum of 35 characters.

Returns:

  • (String)


21
22
23
# File 'lib/plaid/models/payment_initiation_address.rb', line 21

def city
  @city
end

#countryString

The ISO 3166-1 alpha-2 country code where the recipient is located.

Returns:

  • (String)


29
30
31
# File 'lib/plaid/models/payment_initiation_address.rb', line 29

def country
  @country
end

#postal_codeString

The postal code where the recipient is located. Maximum of 16 characters.

Returns:

  • (String)


25
26
27
# File 'lib/plaid/models/payment_initiation_address.rb', line 25

def postal_code
  @postal_code
end

#streetArray[String]

An array of length 1-2 representing the street address where the recipient is located. Maximum of 70 characters.

Returns:

  • (Array[String])


17
18
19
# File 'lib/plaid/models/payment_initiation_address.rb', line 17

def street
  @street
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/plaid/models/payment_initiation_address.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  street = hash.key?('street') ? hash['street'] : nil
  city = hash.key?('city') ? hash['city'] : nil
  postal_code = hash.key?('postal_code') ? hash['postal_code'] : nil
  country = hash.key?('country') ? hash['country'] : nil

  # 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.
  PaymentInitiationAddress.new(street: street,
                               city: city,
                               postal_code: postal_code,
                               country: country,
                               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



32
33
34
35
36
37
38
39
# File 'lib/plaid/models/payment_initiation_address.rb', line 32

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['street'] = 'street'
  @_hash['city'] = 'city'
  @_hash['postal_code'] = 'postal_code'
  @_hash['country'] = 'country'
  @_hash
end

.nullablesObject

An array for nullable fields



47
48
49
# File 'lib/plaid/models/payment_initiation_address.rb', line 47

def self.nullables
  []
end

.optionalsObject

An array for optional fields



42
43
44
# File 'lib/plaid/models/payment_initiation_address.rb', line 42

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



96
97
98
99
100
101
# File 'lib/plaid/models/payment_initiation_address.rb', line 96

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} street: #{@street.inspect}, city: #{@city.inspect}, postal_code:"\
  " #{@postal_code.inspect}, country: #{@country.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



89
90
91
92
93
# File 'lib/plaid/models/payment_initiation_address.rb', line 89

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} street: #{@street}, city: #{@city}, postal_code: #{@postal_code}, country:"\
  " #{@country}, additional_properties: #{@additional_properties}>"
end