Class: ThePlaidApi::LinkTokenCreateResponse

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

Overview

LinkTokenCreateResponse defines the response schema for ‘/link/token/create`

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:, expiration:, request_id:, hosted_link_url: SKIP, user_id: SKIP, additional_properties: nil) ⇒ LinkTokenCreateResponse

Returns a new instance of LinkTokenCreateResponse.



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 80

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

  @link_token = link_token
  @expiration = expiration
  @request_id = request_id
  @hosted_link_url = hosted_link_url unless hosted_link_url == SKIP
  @user_id = user_id unless user_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#expirationDateTime

The expiration date and time for the ‘link_token`, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format. By default, a `link_token` created to generate a `public_token` that will be exchanged for a new `access_token` expires after 4 hours, and a `link_token` created for an existing Item (such as when updating an existing `access_token` by launching Link in update mode) expires after 30 minutes. If using [Hosted Link](plaid.com/docs/link/hosted-link/), the `link_token` will expire at the same time as the Hosted Link URL, and you can customize the duration using the `hosted_link.url_lifetime_seconds` option in the request. If using Link Delivery (beta), the `link_token` will expire by default after 24 hours if sent via SMS and after 7 days if sent via email. If using Identity Verification, Link token expiration will not be enforced; an Identity Verification Link session can be created with an expired Link token.

Returns:

  • (DateTime)


34
35
36
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 34

def expiration
  @expiration
end

A URL of a Plaid-hosted Link flow that will use the Link token returned by this request. Only present if the session is enabled for Hosted Link. To enable the session for Hosted Link, send a ‘hosted_link` object in the request.

Returns:

  • (String)


47
48
49
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 47

def hosted_link_url
  @hosted_link_url
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_create_response.rb', line 17

def link_token
  @link_token
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)


40
41
42
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 40

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)


54
55
56
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 54

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 94

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  link_token = hash.key?('link_token') ? hash['link_token'] : nil
  expiration = if hash.key?('expiration')
                 (DateTimeHelper.from_rfc3339(hash['expiration']) if hash['expiration'])
               end
  request_id = hash.key?('request_id') ? hash['request_id'] : nil
  hosted_link_url =
    hash.key?('hosted_link_url') ? hash['hosted_link_url'] : SKIP
  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.
  LinkTokenCreateResponse.new(link_token: link_token,
                              expiration: expiration,
                              request_id: request_id,
                              hosted_link_url: hosted_link_url,
                              user_id: user_id,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



57
58
59
60
61
62
63
64
65
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 57

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

.nullablesObject

An array for nullable fields



76
77
78
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 76

def self.nullables
  []
end

.optionalsObject

An array for optional fields



68
69
70
71
72
73
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 68

def self.optionals
  %w[
    hosted_link_url
    user_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



136
137
138
139
140
141
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 136

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

#to_custom_expirationObject



123
124
125
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 123

def to_custom_expiration
  DateTimeHelper.to_rfc3339(expiration)
end

#to_sObject

Provides a human-readable string representation of the object.



128
129
130
131
132
133
# File 'lib/the_plaid_api/models/link_token_create_response.rb', line 128

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