Class: ThePlaidApi::PendingDisconnectWebhook

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

Overview

Fired when an Item is expected to be disconnected. The webhook will currently be fired 7 days before the existing Item is scheduled for disconnection. This can be resolved by having the user go through Link’s [update mode](plaid.com/docs/link/update-mode). Currently, this webhook is fired only for US or Canadian institutions; in the UK or EU, you should continue to listed for the [‘PENDING_EXPIRATION`](plaid.com/docs/api/items/#pending_expiration) webhook instead.

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(webhook_type:, webhook_code:, item_id:, reason:, disconnect_time:, environment:, user_id: SKIP, additional_properties: nil) ⇒ PendingDisconnectWebhook

Returns a new instance of PendingDisconnectWebhook.



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

def initialize(webhook_type:, webhook_code:, item_id:, reason:,
               disconnect_time:, environment:, user_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @webhook_type = webhook_type
  @webhook_code = webhook_code
  @item_id = item_id
  @user_id = user_id unless user_id == SKIP
  @reason = reason
  @disconnect_time = disconnect_time
  @environment = environment
  @additional_properties = additional_properties
end

Instance Attribute Details

#disconnect_timeDateTime

The date and time at which the Item is scheduled to disconnect, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format.

Returns:

  • (DateTime)


49
50
51
# File 'lib/the_plaid_api/models/pending_disconnect_webhook.rb', line 49

def disconnect_time
  @disconnect_time
end

#environmentWebhookEnvironmentValues

The Plaid environment the webhook was sent from



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

def environment
  @environment
end

#item_idString

The ‘item_id` of the Item associated with this webhook, warning, or error

Returns:

  • (String)


30
31
32
# File 'lib/the_plaid_api/models/pending_disconnect_webhook.rb', line 30

def item_id
  @item_id
end

#reasonPendingDisconnectWebhookReason

Reason why the item is about to be disconnected. ‘INSTITUTION_MIGRATION`: The institution is moving to API or to a different integration. For example, this can occur when an institution moves from a non-OAuth integration to an OAuth integration. `INSTITUTION_TOKEN_EXPIRATION`: The consent on an Item associated with a US or CA institution is about to expire.



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

def reason
  @reason
end

#user_idString

The Plaid ‘user_id` of the User associated with this webhook, warning, or error.

Returns:

  • (String)


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

def user_id
  @user_id
end

#webhook_codeString

‘PENDING_DISCONNECT`

Returns:

  • (String)


26
27
28
# File 'lib/the_plaid_api/models/pending_disconnect_webhook.rb', line 26

def webhook_code
  @webhook_code
end

#webhook_typeString

‘ITEM`

Returns:

  • (String)


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

def webhook_type
  @webhook_type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
122
123
124
125
126
127
# File 'lib/the_plaid_api/models/pending_disconnect_webhook.rb', line 97

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  webhook_type = hash.key?('webhook_type') ? hash['webhook_type'] : nil
  webhook_code = hash.key?('webhook_code') ? hash['webhook_code'] : nil
  item_id = hash.key?('item_id') ? hash['item_id'] : nil
  reason = hash.key?('reason') ? hash['reason'] : nil
  disconnect_time = if hash.key?('disconnect_time')
                      (DateTimeHelper.from_rfc3339(hash['disconnect_time']) if hash['disconnect_time'])
                    end
  environment = hash.key?('environment') ? hash['environment'] : nil
  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.
  PendingDisconnectWebhook.new(webhook_type: webhook_type,
                               webhook_code: webhook_code,
                               item_id: item_id,
                               reason: reason,
                               disconnect_time: disconnect_time,
                               environment: environment,
                               user_id: user_id,
                               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['webhook_type'] = 'webhook_type'
  @_hash['webhook_code'] = 'webhook_code'
  @_hash['item_id'] = 'item_id'
  @_hash['user_id'] = 'user_id'
  @_hash['reason'] = 'reason'
  @_hash['disconnect_time'] = 'disconnect_time'
  @_hash['environment'] = 'environment'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    user_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



143
144
145
146
147
148
149
# File 'lib/the_plaid_api/models/pending_disconnect_webhook.rb', line 143

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} webhook_type: #{@webhook_type.inspect}, webhook_code:"\
  " #{@webhook_code.inspect}, item_id: #{@item_id.inspect}, user_id: #{@user_id.inspect},"\
  " reason: #{@reason.inspect}, disconnect_time: #{@disconnect_time.inspect}, environment:"\
  " #{@environment.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_disconnect_timeObject



129
130
131
# File 'lib/the_plaid_api/models/pending_disconnect_webhook.rb', line 129

def to_custom_disconnect_time
  DateTimeHelper.to_rfc3339(disconnect_time)
end

#to_sObject

Provides a human-readable string representation of the object.



134
135
136
137
138
139
140
# File 'lib/the_plaid_api/models/pending_disconnect_webhook.rb', line 134

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} webhook_type: #{@webhook_type}, webhook_code: #{@webhook_code}, item_id:"\
  " #{@item_id}, user_id: #{@user_id}, reason: #{@reason}, disconnect_time:"\
  " #{@disconnect_time}, environment: #{@environment}, additional_properties:"\
  " #{@additional_properties}>"
end