Class: SecureNative::EventOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/securenative/event_options.rb

Constant Summary collapse

MAX_PROPERTIES_SIZE =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event: nil, user_id: nil, user_traits: nil, user_name: nil, email: nil, phone: nil, created_at: nil, context: nil, properties: nil, timestamp: nil) ⇒ EventOptions

Returns a new instance of EventOptions.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/securenative/event_options.rb', line 10

def initialize(event: nil, user_id: nil, user_traits: nil, user_name: nil, email: nil, phone: nil, created_at: nil, context: nil, properties: nil, timestamp: nil)
  if !properties.nil? && properties.length > MAX_PROPERTIES_SIZE
    raise SecureNativeInvalidOptionsError, "You can have only up to #{MAX_PROPERTIES_SIZE} custom properties"
  end

  if user_traits.nil?
    if user_name && email && phone && created_at
      user_traits = SecureNative::UserTraits(user_name, email, phone, created_at)
    elsif user_name && email && phone
      user_traits = SecureNative::UserTraits(user_name, email, phone)
    elsif user_name && email
      user_traits = SecureNative::UserTraits(user_name, email)
    else
      user_traits = UserTraits.new
    end
  end

  @event = event
  @user_id = user_id
  @user_traits = user_traits
  @context = context
  @properties = properties
  @timestamp = timestamp
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



5
6
7
# File 'lib/securenative/event_options.rb', line 5

def context
  @context
end

#eventObject

Returns the value of attribute event.



5
6
7
# File 'lib/securenative/event_options.rb', line 5

def event
  @event
end

#propertiesObject

Returns the value of attribute properties.



5
6
7
# File 'lib/securenative/event_options.rb', line 5

def properties
  @properties
end

#timestampObject

Returns the value of attribute timestamp.



5
6
7
# File 'lib/securenative/event_options.rb', line 5

def timestamp
  @timestamp
end

#user_idObject

Returns the value of attribute user_id.



5
6
7
# File 'lib/securenative/event_options.rb', line 5

def user_id
  @user_id
end

#user_traitsObject

Returns the value of attribute user_traits.



5
6
7
# File 'lib/securenative/event_options.rb', line 5

def user_traits
  @user_traits
end