Class: ThePlaidApi::ProtectEvent

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

Overview

Event data for Protect events.

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(timestamp:, protect_session_id: SKIP, app_visit: SKIP, user_sign_in: SKIP, user_sign_up: SKIP, additional_properties: nil) ⇒ ProtectEvent

Returns a new instance of ProtectEvent.



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/the_plaid_api/models/protect_event.rb', line 66

def initialize(timestamp:, protect_session_id: SKIP, app_visit: SKIP,
               user_sign_in: SKIP, user_sign_up: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @timestamp = timestamp
  @protect_session_id = protect_session_id unless protect_session_id == SKIP
  @app_visit = app_visit unless app_visit == SKIP
  @user_sign_in =  unless  == SKIP
  @user_sign_up =  unless  == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#app_visitObject

This event type represents a user visiting the client application.

Returns:

  • (Object)


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

def app_visit
  @app_visit
end

#protect_session_idString

If present, contains the current Protect Session ID from the Plaid Pixel SDK.

Returns:

  • (String)


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

def protect_session_id
  @protect_session_id
end

#timestampDateTime

The timestamp of the event, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format, e.g. ā€˜ā€œ2017-09-14T14:42:19.350Zā€`

Returns:

  • (DateTime)


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

def timestamp
  @timestamp
end

#user_sign_inObject

This event type represents a user signing in to the application.

Returns:

  • (Object)


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

def 
  @user_sign_in
end

#user_sign_upObject

This event type represents a user signing up for the application.

Returns:

  • (Object)


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

def 
  @user_sign_up
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/the_plaid_api/models/protect_event.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  timestamp = if hash.key?('timestamp')
                (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp'])
              end
  protect_session_id =
    hash.key?('protect_session_id') ? hash['protect_session_id'] : SKIP
  app_visit = hash.key?('app_visit') ? hash['app_visit'] : SKIP
   = hash.key?('user_sign_in') ? hash['user_sign_in'] : SKIP
   = hash.key?('user_sign_up') ? hash['user_sign_up'] : 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.
  ProtectEvent.new(timestamp: timestamp,
                   protect_session_id: protect_session_id,
                   app_visit: app_visit,
                   user_sign_in: ,
                   user_sign_up: ,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
# File 'lib/the_plaid_api/models/protect_event.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['timestamp'] = 'timestamp'
  @_hash['protect_session_id'] = 'protect_session_id'
  @_hash['app_visit'] = 'app_visit'
  @_hash['user_sign_in'] = 'user_sign_in'
  @_hash['user_sign_up'] = 'user_sign_up'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    app_visit
    user_sign_in
    user_sign_up
  ]
end

.optionalsObject

An array for optional fields



48
49
50
51
52
53
54
55
# File 'lib/the_plaid_api/models/protect_event.rb', line 48

def self.optionals
  %w[
    protect_session_id
    app_visit
    user_sign_in
    user_sign_up
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



123
124
125
126
127
128
129
# File 'lib/the_plaid_api/models/protect_event.rb', line 123

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} timestamp: #{@timestamp.inspect}, protect_session_id:"\
  " #{@protect_session_id.inspect}, app_visit: #{@app_visit.inspect}, user_sign_in:"\
  " #{@user_sign_in.inspect}, user_sign_up: #{@user_sign_up.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_timestampObject



110
111
112
# File 'lib/the_plaid_api/models/protect_event.rb', line 110

def to_custom_timestamp
  DateTimeHelper.to_rfc3339(timestamp)
end

#to_sObject

Provides a human-readable string representation of the object.



115
116
117
118
119
120
# File 'lib/the_plaid_api/models/protect_event.rb', line 115

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} timestamp: #{@timestamp}, protect_session_id: #{@protect_session_id},"\
  " app_visit: #{@app_visit}, user_sign_in: #{@user_sign_in}, user_sign_up: #{@user_sign_up},"\
  " additional_properties: #{@additional_properties}>"
end