Class: NewStoreApi::Actor

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/actor.rb

Overview

Who (or what) caused the audited change. Sourced from the caller's JWT; empty fields are omitted from the payload.

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(authenticated_at = SKIP, authorized_party = SKIP, display_name = SKIP, idp_user_id = SKIP, session_id = SKIP, token_id = SKIP, user_id = SKIP) ⇒ Actor

Returns a new instance of Actor.



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/new_store_api/models/actor.rb', line 73

def initialize(authenticated_at = SKIP, authorized_party = SKIP,
               display_name = SKIP, idp_user_id = SKIP, session_id = SKIP,
               token_id = SKIP, user_id = SKIP)
  @authenticated_at = authenticated_at unless authenticated_at == SKIP
  @authorized_party = authorized_party unless authorized_party == SKIP
  @display_name = display_name unless display_name == SKIP
  @idp_user_id = idp_user_id unless idp_user_id == SKIP
  @session_id = session_id unless session_id == SKIP
  @token_id = token_id unless token_id == SKIP
  @user_id = user_id unless user_id == SKIP
end

Instance Attribute Details

#authenticated_atDateTime

When the actor authenticated (from the JWT auth_time claim).

Returns:

  • (DateTime)


16
17
18
# File 'lib/new_store_api/models/actor.rb', line 16

def authenticated_at
  @authenticated_at
end

#authorized_partyString

JWT azp — channel or integration that called the API.

Returns:

  • (String)


20
21
22
# File 'lib/new_store_api/models/actor.rb', line 20

def authorized_party
  @authorized_party
end

#display_nameString

JWT name.

Returns:

  • (String)


24
25
26
# File 'lib/new_store_api/models/actor.rb', line 24

def display_name
  @display_name
end

#idp_user_idString

JWT sub — IDP user id (human or technical user).

Returns:

  • (String)


28
29
30
# File 'lib/new_store_api/models/actor.rb', line 28

def idp_user_id
  @idp_user_id
end

#session_idString

JWT sid — correlates events in the same auth session.

Returns:

  • (String)


32
33
34
# File 'lib/new_store_api/models/actor.rb', line 32

def session_id
  @session_id
end

#token_idString

JWT jti — per-token identifier.

Returns:

  • (String)


36
37
38
# File 'lib/new_store_api/models/actor.rb', line 36

def token_id
  @token_id
end

#user_idString

Legacy internal NewStore user id.

Returns:

  • (String)


40
41
42
# File 'lib/new_store_api/models/actor.rb', line 40

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/new_store_api/models/actor.rb', line 86

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  authenticated_at = if hash.key?('authenticated_at')
                       (DateTimeHelper.from_rfc3339(hash['authenticated_at']) if hash['authenticated_at'])
                     else
                       SKIP
                     end
  authorized_party =
    hash.key?('authorized_party') ? hash['authorized_party'] : SKIP
  display_name = hash.key?('display_name') ? hash['display_name'] : SKIP
  idp_user_id = hash.key?('idp_user_id') ? hash['idp_user_id'] : SKIP
  session_id = hash.key?('session_id') ? hash['session_id'] : SKIP
  token_id = hash.key?('token_id') ? hash['token_id'] : SKIP
  user_id = hash.key?('user_id') ? hash['user_id'] : SKIP

  # Create object from extracted values.
  Actor.new(authenticated_at,
            authorized_party,
            display_name,
            idp_user_id,
            session_id,
            token_id,
            user_id)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/new_store_api/models/actor.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['authenticated_at'] = 'authenticated_at'
  @_hash['authorized_party'] = 'authorized_party'
  @_hash['display_name'] = 'display_name'
  @_hash['idp_user_id'] = 'idp_user_id'
  @_hash['session_id'] = 'session_id'
  @_hash['token_id'] = 'token_id'
  @_hash['user_id'] = 'user_id'
  @_hash
end

.nullablesObject

An array for nullable fields



69
70
71
# File 'lib/new_store_api/models/actor.rb', line 69

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    authenticated_at
    authorized_party
    display_name
    idp_user_id
    session_id
    token_id
    user_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



126
127
128
129
130
131
132
# File 'lib/new_store_api/models/actor.rb', line 126

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} authenticated_at: #{@authenticated_at.inspect}, authorized_party:"\
  " #{@authorized_party.inspect}, display_name: #{@display_name.inspect}, idp_user_id:"\
  " #{@idp_user_id.inspect}, session_id: #{@session_id.inspect}, token_id:"\
  " #{@token_id.inspect}, user_id: #{@user_id.inspect}>"
end

#to_custom_authenticated_atObject



113
114
115
# File 'lib/new_store_api/models/actor.rb', line 113

def to_custom_authenticated_at
  DateTimeHelper.to_rfc3339(authenticated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



118
119
120
121
122
123
# File 'lib/new_store_api/models/actor.rb', line 118

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} authenticated_at: #{@authenticated_at}, authorized_party:"\
  " #{@authorized_party}, display_name: #{@display_name}, idp_user_id: #{@idp_user_id},"\
  " session_id: #{@session_id}, token_id: #{@token_id}, user_id: #{@user_id}>"
end