Class: SecureNative::SDKEvent
- Inherits:
-
Object
- Object
- SecureNative::SDKEvent
- Defined in:
- lib/securenative/sdk_event.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#event_type ⇒ Object
Returns the value of attribute event_type.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#request ⇒ Object
Returns the value of attribute request.
-
#rid ⇒ Object
Returns the value of attribute rid.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
-
#user_traits ⇒ Object
Returns the value of attribute user_traits.
Instance Method Summary collapse
-
#initialize(event_options, securenative_options) ⇒ SDKEvent
constructor
A new instance of SDKEvent.
- #to_s ⇒ Object
Constructor Details
#initialize(event_options, securenative_options) ⇒ SDKEvent
Returns a new instance of SDKEvent.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/securenative/sdk_event.rb', line 8 def initialize(, ) if .user_id.nil? || .user_id.length <= 0 || .user_id == '' raise SecureNativeInvalidOptionsError.new, 'Invalid event structure; User Id is missing' end if .event.nil? || .event.length <= 0 || .event == '' raise SecureNativeInvalidOptionsError.new, 'Invalid event structure; Event Type is missing' end @context = if !.context.nil? .context else Context.default_context_builder end client_token = SecureNative::Utils::EncryptionUtils.decrypt(@context.client_token, .api_key) @rid = SecureRandom.uuid.to_str @event_type = .event @user_id = .user_id @user_traits = .user_traits @request = RequestContext.new(cid: client_token ? client_token.cid : '', vid: client_token ? client_token.vid : '', fp: client_token ? client_token.fp : '', ip: @context.ip, remote_ip: @context.remote_ip, headers: @context.headers, url: @context.url, http_method: @context.http_method) @timestamp = SecureNative::Utils::DateUtils.(.) @properties = .properties end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
5 6 7 |
# File 'lib/securenative/sdk_event.rb', line 5 def context @context end |
#event_type ⇒ Object
Returns the value of attribute event_type.
5 6 7 |
# File 'lib/securenative/sdk_event.rb', line 5 def event_type @event_type end |
#properties ⇒ Object
Returns the value of attribute properties.
5 6 7 |
# File 'lib/securenative/sdk_event.rb', line 5 def properties @properties end |
#request ⇒ Object
Returns the value of attribute request.
5 6 7 |
# File 'lib/securenative/sdk_event.rb', line 5 def request @request end |
#rid ⇒ Object
Returns the value of attribute rid.
5 6 7 |
# File 'lib/securenative/sdk_event.rb', line 5 def rid @rid end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
5 6 7 |
# File 'lib/securenative/sdk_event.rb', line 5 def @timestamp end |
#user_id ⇒ Object
Returns the value of attribute user_id.
5 6 7 |
# File 'lib/securenative/sdk_event.rb', line 5 def user_id @user_id end |
#user_traits ⇒ Object
Returns the value of attribute user_traits.
5 6 7 |
# File 'lib/securenative/sdk_event.rb', line 5 def user_traits @user_traits end |
Instance Method Details
#to_s ⇒ Object
39 40 41 42 |
# File 'lib/securenative/sdk_event.rb', line 39 def to_s "context: #{@context}, rid: #{@rid}, event_type: #{@event_type}, user_id: #{@user_id}, user_traits: #{@user_traits}, request: #{@request}, timestamp: #{@timestamp}, properties: #{@properties}" end |