Class: ThePlaidApi::ConsentEvent

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

Overview

Describes a consent event.

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(item_id: SKIP, created_at: SKIP, event_type: SKIP, event_code: SKIP, institution_id: SKIP, institution_name: SKIP, initiator: SKIP, consented_use_cases: SKIP, consented_data_scopes: SKIP, consented_accounts: SKIP, additional_properties: nil) ⇒ ConsentEvent

Returns a new instance of ConsentEvent.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/the_plaid_api/models/consent_event.rb', line 108

def initialize(item_id: SKIP, created_at: SKIP, event_type: SKIP,
               event_code: SKIP, institution_id: SKIP,
               institution_name: SKIP, initiator: SKIP,
               consented_use_cases: SKIP, consented_data_scopes: SKIP,
               consented_accounts: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @item_id = item_id unless item_id == SKIP
  @created_at = created_at unless created_at == SKIP
  @event_type = event_type unless event_type == SKIP
  @event_code = event_code unless event_code == SKIP
  @institution_id = institution_id unless institution_id == SKIP
  @institution_name = institution_name unless institution_name == SKIP
  @initiator = initiator unless initiator == SKIP
  @consented_use_cases = consented_use_cases unless consented_use_cases == SKIP
  @consented_data_scopes = consented_data_scopes unless consented_data_scopes == SKIP
  @consented_accounts = consented_accounts unless consented_accounts == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#consented_accountsArray[ConsentedAccount]

An array containing the accounts associated with the Item for which authorizations are granted.

Returns:



66
67
68
# File 'lib/the_plaid_api/models/consent_event.rb', line 66

def consented_accounts
  @consented_accounts
end

#consented_data_scopesArray[String]

A list of strings containing the full list of data scopes the end user has consented to for the Item. These correspond to consented products; see the [full mapping](plaid.com/docs/link/data-transparency-messaging-migration -guide/#data-scopes-by-product) of data scopes and products.

Returns:

  • (Array[String])


61
62
63
# File 'lib/the_plaid_api/models/consent_event.rb', line 61

def consented_data_scopes
  @consented_data_scopes
end

#consented_use_casesArray[String]

A list of strings containing the full list of use cases the end user has consented to for the Item. See the [full list](plaid.com/docs/link/data-transparency-messaging-migration-gu ide/#updating-link-customizations) of use cases.

Returns:

  • (Array[String])


53
54
55
# File 'lib/the_plaid_api/models/consent_event.rb', line 53

def consented_use_cases
  @consented_use_cases
end

#created_atDateTime

The date and time when the consent event occurred, in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:

  • (DateTime)


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

def created_at
  @created_at
end

#event_codeConsentEventCode

Codes describing the object of a consent event.

Returns:



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

def event_code
  @event_code
end

#event_typeConsentEventType

A broad categorization of the consent event.

Returns:



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

def event_type
  @event_type
end

#initiatorConsentEventInitiator

The entity that initiated collection of consent.



45
46
47
# File 'lib/the_plaid_api/models/consent_event.rb', line 45

def initiator
  @initiator
end

#institution_idString

Unique identifier for the institution associated with the Item. Field is ‘null` for Items created via Same Day Micro-deposits.

Returns:

  • (String)


36
37
38
# File 'lib/the_plaid_api/models/consent_event.rb', line 36

def institution_id
  @institution_id
end

#institution_nameString

The full name of the institution associated with the Item. Field is ‘null` for Items created via Same Day Micro-deposits.

Returns:

  • (String)


41
42
43
# File 'lib/the_plaid_api/models/consent_event.rb', line 41

def institution_name
  @institution_name
end

#item_idString

The Plaid Item ID. The ‘item_id` is always unique; linking the same account at the same institution twice will result in two Items with different `item_id` values. Like all Plaid identifiers, the `item_id` is case-sensitive.

Returns:

  • (String)


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

def item_id
  @item_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/the_plaid_api/models/consent_event.rb', line 130

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  item_id = hash.key?('item_id') ? hash['item_id'] : SKIP
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  event_type = hash.key?('event_type') ? hash['event_type'] : SKIP
  event_code = hash.key?('event_code') ? hash['event_code'] : SKIP
  institution_id =
    hash.key?('institution_id') ? hash['institution_id'] : SKIP
  institution_name =
    hash.key?('institution_name') ? hash['institution_name'] : SKIP
  initiator = hash.key?('initiator') ? hash['initiator'] : SKIP
  consented_use_cases =
    hash.key?('consented_use_cases') ? hash['consented_use_cases'] : SKIP
  consented_data_scopes =
    hash.key?('consented_data_scopes') ? hash['consented_data_scopes'] : SKIP
  # Parameter is an array, so we need to iterate through it
  consented_accounts = nil
  unless hash['consented_accounts'].nil?
    consented_accounts = []
    hash['consented_accounts'].each do |structure|
      consented_accounts << (ConsentedAccount.from_hash(structure) if structure)
    end
  end

  consented_accounts = SKIP unless hash.key?('consented_accounts')

  # 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.
  ConsentEvent.new(item_id: item_id,
                   created_at: created_at,
                   event_type: event_type,
                   event_code: event_code,
                   institution_id: institution_id,
                   institution_name: institution_name,
                   initiator: initiator,
                   consented_use_cases: consented_use_cases,
                   consented_data_scopes: consented_data_scopes,
                   consented_accounts: consented_accounts,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/the_plaid_api/models/consent_event.rb', line 69

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['item_id'] = 'item_id'
  @_hash['created_at'] = 'created_at'
  @_hash['event_type'] = 'event_type'
  @_hash['event_code'] = 'event_code'
  @_hash['institution_id'] = 'institution_id'
  @_hash['institution_name'] = 'institution_name'
  @_hash['initiator'] = 'initiator'
  @_hash['consented_use_cases'] = 'consented_use_cases'
  @_hash['consented_data_scopes'] = 'consented_data_scopes'
  @_hash['consented_accounts'] = 'consented_accounts'
  @_hash
end

.nullablesObject

An array for nullable fields



101
102
103
104
105
106
# File 'lib/the_plaid_api/models/consent_event.rb', line 101

def self.nullables
  %w[
    institution_id
    institution_name
  ]
end

.optionalsObject

An array for optional fields



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/the_plaid_api/models/consent_event.rb', line 85

def self.optionals
  %w[
    item_id
    created_at
    event_type
    event_code
    institution_id
    institution_name
    initiator
    consented_use_cases
    consented_data_scopes
    consented_accounts
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



199
200
201
202
203
204
205
206
207
# File 'lib/the_plaid_api/models/consent_event.rb', line 199

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} item_id: #{@item_id.inspect}, created_at: #{@created_at.inspect},"\
  " event_type: #{@event_type.inspect}, event_code: #{@event_code.inspect}, institution_id:"\
  " #{@institution_id.inspect}, institution_name: #{@institution_name.inspect}, initiator:"\
  " #{@initiator.inspect}, consented_use_cases: #{@consented_use_cases.inspect},"\
  " consented_data_scopes: #{@consented_data_scopes.inspect}, consented_accounts:"\
  " #{@consented_accounts.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_created_atObject



183
184
185
# File 'lib/the_plaid_api/models/consent_event.rb', line 183

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_sObject

Provides a human-readable string representation of the object.



188
189
190
191
192
193
194
195
196
# File 'lib/the_plaid_api/models/consent_event.rb', line 188

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} item_id: #{@item_id}, created_at: #{@created_at}, event_type:"\
  " #{@event_type}, event_code: #{@event_code}, institution_id: #{@institution_id},"\
  " institution_name: #{@institution_name}, initiator: #{@initiator}, consented_use_cases:"\
  " #{@consented_use_cases}, consented_data_scopes: #{@consented_data_scopes},"\
  " consented_accounts: #{@consented_accounts}, additional_properties:"\
  " #{@additional_properties}>"
end