Class: ThePlaidApi::LinkTokenGetResponse

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

Overview

LinkTokenGetResponse defines the response schema for ‘/link/token/get`

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(link_token:, created_at:, expiration:, metadata:, request_id:, link_sessions: SKIP, user_id: SKIP, additional_properties: nil) ⇒ LinkTokenGetResponse

Returns a new instance of LinkTokenGetResponse.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 81

def initialize(link_token:, created_at:, expiration:, metadata:,
               request_id:, link_sessions: SKIP, user_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @link_token = link_token
  @created_at = created_at
  @expiration = expiration
  @link_sessions = link_sessions unless link_sessions == SKIP
  @metadata = 
  @user_id = user_id unless user_id == SKIP
  @request_id = request_id
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_atDateTime

The creation timestamp for the ‘link_token`, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format.

Returns:

  • (DateTime)


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

def created_at
  @created_at
end

#expirationDateTime

The expiration timestamp for the ‘link_token`, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format.

Returns:

  • (DateTime)


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

def expiration
  @expiration
end

Information about Link sessions created using this ‘link_token`. Session data will be provided for up to six hours after the session has ended.

Returns:



32
33
34
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 32

def link_sessions
  @link_sessions
end

A ‘link_token`, which can be supplied to Link in order to initialize it and receive a `public_token`, which can be exchanged for an `access_token`.

Returns:

  • (String)


17
18
19
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 17

def link_token
  @link_token
end

#metadataLinkTokenGetMetadataResponse

An object specifying the arguments originally provided to the ‘/link/token/create` call.



37
38
39
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 37

def 
  @metadata
end

#request_idString

A unique identifier for the request, which can be used for troubleshooting. This identifier, like all Plaid identifiers, is case sensitive.

Returns:

  • (String)


50
51
52
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 50

def request_id
  @request_id
end

#user_idString

A unique user identifier, created by ‘/user/create`. Integrations that began using `/user/create` after December 10, 2025 use this field to identify a user instead of the `user_token`. For more details, see [new user APIs](plaid.com/docs/api/users/user-apis).

Returns:

  • (String)


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

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



98
99
100
101
102
103
104
105
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
137
138
139
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 98

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  link_token = hash.key?('link_token') ? hash['link_token'] : nil
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  expiration = if hash.key?('expiration')
                 (DateTimeHelper.from_rfc3339(hash['expiration']) if hash['expiration'])
               end
   = LinkTokenGetMetadataResponse.from_hash(hash['metadata']) if hash['metadata']
  request_id = hash.key?('request_id') ? hash['request_id'] : nil
  # Parameter is an array, so we need to iterate through it
  link_sessions = nil
  unless hash['link_sessions'].nil?
    link_sessions = []
    hash['link_sessions'].each do |structure|
      link_sessions << (LinkTokenGetSessionsResponse.from_hash(structure) if structure)
    end
  end

  link_sessions = SKIP unless hash.key?('link_sessions')
  user_id = hash.key?('user_id') ? hash['user_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.
  LinkTokenGetResponse.new(link_token: link_token,
                           created_at: created_at,
                           expiration: expiration,
                           metadata: ,
                           request_id: request_id,
                           link_sessions: link_sessions,
                           user_id: user_id,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 53

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['link_token'] = 'link_token'
  @_hash['created_at'] = 'created_at'
  @_hash['expiration'] = 'expiration'
  @_hash['link_sessions'] = 'link_sessions'
  @_hash['metadata'] = 'metadata'
  @_hash['user_id'] = 'user_id'
  @_hash['request_id'] = 'request_id'
  @_hash
end

.nullablesObject

An array for nullable fields



74
75
76
77
78
79
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 74

def self.nullables
  %w[
    created_at
    expiration
  ]
end

.optionalsObject

An array for optional fields



66
67
68
69
70
71
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 66

def self.optionals
  %w[
    link_sessions
    user_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



159
160
161
162
163
164
165
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 159

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} link_token: #{@link_token.inspect}, created_at: #{@created_at.inspect},"\
  " expiration: #{@expiration.inspect}, link_sessions: #{@link_sessions.inspect}, metadata:"\
  " #{@metadata.inspect}, user_id: #{@user_id.inspect}, request_id: #{@request_id.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_created_atObject



141
142
143
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 141

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_expirationObject



145
146
147
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 145

def to_custom_expiration
  DateTimeHelper.to_rfc3339(expiration)
end

#to_sObject

Provides a human-readable string representation of the object.



150
151
152
153
154
155
156
# File 'lib/the_plaid_api/models/link_token_get_response.rb', line 150

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} link_token: #{@link_token}, created_at: #{@created_at}, expiration:"\
  " #{@expiration}, link_sessions: #{@link_sessions}, metadata: #{@metadata}, user_id:"\
  " #{@user_id}, request_id: #{@request_id}, additional_properties:"\
  " #{@additional_properties}>"
end