Class: ThePlaidApi::ProtectUserInsightsGetResponse

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

Overview

Response object for /protect/user/insights/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(user_id:, latest_scored_event:, request_id:, reports: SKIP, additional_properties: nil) ⇒ ProtectUserInsightsGetResponse

Returns a new instance of ProtectUserInsightsGetResponse.



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

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

  @user_id = user_id
  @latest_scored_event = latest_scored_event
  @reports = reports unless reports == SKIP
  @request_id = request_id
  @additional_properties = additional_properties
end

Instance Attribute Details

#latest_scored_eventLatestScoredEvent

The latest scored event for a user.

Returns:



20
21
22
# File 'lib/the_plaid_api/models/protect_user_insights_get_response.rb', line 20

def latest_scored_event
  @latest_scored_event
end

#reportsArray[ProtectReport]

List of Protect reports associated with this user, limited to the most recent 100 reports in reverse chronological order (newest first).

Returns:



25
26
27
# File 'lib/the_plaid_api/models/protect_user_insights_get_response.rb', line 25

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


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

def request_id
  @request_id
end

#user_idString

The Plaid User ID. If a ‘client_user_id` was provided in the request instead of a `user_id`, a new `user_id` will be generated if one doesn’t already exist for that ‘client_user_id`.

Returns:

  • (String)


16
17
18
# File 'lib/the_plaid_api/models/protect_user_insights_get_response.rb', line 16

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/the_plaid_api/models/protect_user_insights_get_response.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  user_id = hash.key?('user_id') ? hash['user_id'] : nil
  latest_scored_event = LatestScoredEvent.from_hash(hash['latest_scored_event']) if
    hash['latest_scored_event']
  request_id = hash.key?('request_id') ? hash['request_id'] : nil
  # Parameter is an array, so we need to iterate through it
  reports = nil
  unless hash['reports'].nil?
    reports = []
    hash['reports'].each do |structure|
      reports << (ProtectReport.from_hash(structure) if structure)
    end
  end

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

  # 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.
  ProtectUserInsightsGetResponse.new(user_id: user_id,
                                     latest_scored_event: latest_scored_event,
                                     request_id: request_id,
                                     reports: reports,
                                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
# File 'lib/the_plaid_api/models/protect_user_insights_get_response.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['user_id'] = 'user_id'
  @_hash['latest_scored_event'] = 'latest_scored_event'
  @_hash['reports'] = 'reports'
  @_hash['request_id'] = 'request_id'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
54
55
# File 'lib/the_plaid_api/models/protect_user_insights_get_response.rb', line 51

def self.nullables
  %w[
    latest_scored_event
  ]
end

.optionalsObject

An array for optional fields



44
45
46
47
48
# File 'lib/the_plaid_api/models/protect_user_insights_get_response.rb', line 44

def self.optionals
  %w[
    reports
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



113
114
115
116
117
118
# File 'lib/the_plaid_api/models/protect_user_insights_get_response.rb', line 113

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

#to_sObject

Provides a human-readable string representation of the object.



105
106
107
108
109
110
# File 'lib/the_plaid_api/models/protect_user_insights_get_response.rb', line 105

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