Class: WorkOS::EventContext

Inherits:
Types::BaseModel show all
Defined in:
lib/workos/shared/event_context.rb

Constant Summary collapse

HASH_ATTRS =
{
  google_analytics_client_id: :google_analytics_client_id,
  google_analytics_sessions: :google_analytics_sessions,
  ajs_anonymous_id: :ajs_anonymous_id,
  client_id: :client_id,
  actor: :actor,
  previous_attributes: :previous_attributes
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Types::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Types::BaseModel

normalize

Methods included from HashProvider

#inspect, #to_h, #to_json

Constructor Details

#initialize(json) ⇒ EventContext

Returns a new instance of EventContext.



24
25
26
27
28
29
30
31
32
# File 'lib/workos/shared/event_context.rb', line 24

def initialize(json)
  hash = self.class.normalize(json)
  @google_analytics_client_id = hash[:google_analytics_client_id]
  @google_analytics_sessions = (hash[:google_analytics_sessions] || []).map { |item| item ? WorkOS::EventContextGoogleAnalyticsSession.new(item) : nil }
  @ajs_anonymous_id = hash[:ajs_anonymous_id]
  @client_id = hash[:client_id]
  @actor = hash[:actor] ? WorkOS::EventContextActor.new(hash[:actor]) : nil
  @previous_attributes = hash[:previous_attributes] || {}
end

Instance Attribute Details

#actorObject

Returns the value of attribute actor.



16
17
18
# File 'lib/workos/shared/event_context.rb', line 16

def actor
  @actor
end

#ajs_anonymous_idObject

Returns the value of attribute ajs_anonymous_id.



16
17
18
# File 'lib/workos/shared/event_context.rb', line 16

def ajs_anonymous_id
  @ajs_anonymous_id
end

#client_idObject

Returns the value of attribute client_id.



16
17
18
# File 'lib/workos/shared/event_context.rb', line 16

def client_id
  @client_id
end

#google_analytics_client_idObject

Returns the value of attribute google_analytics_client_id.



16
17
18
# File 'lib/workos/shared/event_context.rb', line 16

def google_analytics_client_id
  @google_analytics_client_id
end

#google_analytics_sessionsObject

Returns the value of attribute google_analytics_sessions.



16
17
18
# File 'lib/workos/shared/event_context.rb', line 16

def google_analytics_sessions
  @google_analytics_sessions
end

#previous_attributesObject

Returns the value of attribute previous_attributes.



16
17
18
# File 'lib/workos/shared/event_context.rb', line 16

def previous_attributes
  @previous_attributes
end