Class: ThePlaidApi::Address2

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/address2.rb

Overview

Address on the paystub

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(city: SKIP, country: SKIP, postal_code: SKIP, region: SKIP, street: SKIP, line1: SKIP, line2: SKIP, state_code: SKIP, additional_properties: nil) ⇒ Address2

Returns a new instance of Address2.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/the_plaid_api/models/address2.rb', line 88

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

  @city = city unless city == SKIP
  @country = country unless country == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @region = region unless region == SKIP
  @street = street unless street == SKIP
  @line1 = line1 unless line1 == SKIP
  @line2 = line2 unless line2 == SKIP
  @state_code = state_code unless state_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#cityString

The full city name.

Returns:

  • (String)


14
15
16
# File 'lib/the_plaid_api/models/address2.rb', line 14

def city
  @city
end

#countryString

The ISO 3166-1 alpha-2 country code.

Returns:

  • (String)


18
19
20
# File 'lib/the_plaid_api/models/address2.rb', line 18

def country
  @country
end

#line1String

Street address line 1.

Returns:

  • (String)


35
36
37
# File 'lib/the_plaid_api/models/address2.rb', line 35

def line1
  @line1
end

#line2String

Street address line 2.

Returns:

  • (String)


39
40
41
# File 'lib/the_plaid_api/models/address2.rb', line 39

def line2
  @line2
end

#postal_codeString

The postal code of the address.

Returns:

  • (String)


22
23
24
# File 'lib/the_plaid_api/models/address2.rb', line 22

def postal_code
  @postal_code
end

#regionString

The region or state Example: ‘“NC”`

Returns:

  • (String)


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

def region
  @region
end

#state_codeString

The region or state Example: ‘“NC”`

Returns:

  • (String)


44
45
46
# File 'lib/the_plaid_api/models/address2.rb', line 44

def state_code
  @state_code
end

#streetString

The full street address.

Returns:

  • (String)


31
32
33
# File 'lib/the_plaid_api/models/address2.rb', line 31

def street
  @street
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/the_plaid_api/models/address2.rb', line 106

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  city = hash.key?('city') ? hash['city'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  postal_code = hash.key?('postal_code') ? hash['postal_code'] : SKIP
  region = hash.key?('region') ? hash['region'] : SKIP
  street = hash.key?('street') ? hash['street'] : SKIP
  line1 = hash.key?('line1') ? hash['line1'] : SKIP
  line2 = hash.key?('line2') ? hash['line2'] : SKIP
  state_code = hash.key?('state_code') ? hash['state_code'] : 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.
  Address2.new(city: city,
               country: country,
               postal_code: postal_code,
               region: region,
               street: street,
               line1: line1,
               line2: line2,
               state_code: state_code,
               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/the_plaid_api/models/address2.rb', line 47

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

.nullablesObject

An array for nullable fields



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/the_plaid_api/models/address2.rb', line 75

def self.nullables
  %w[
    city
    country
    postal_code
    region
    street
    line1
    line2
    state_code
  ]
end

.optionalsObject

An array for optional fields



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/the_plaid_api/models/address2.rb', line 61

def self.optionals
  %w[
    city
    country
    postal_code
    region
    street
    line1
    line2
    state_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



147
148
149
150
151
152
153
# File 'lib/the_plaid_api/models/address2.rb', line 147

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

#to_sObject

Provides a human-readable string representation of the object.



139
140
141
142
143
144
# File 'lib/the_plaid_api/models/address2.rb', line 139

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