Sha256: dbfd5efa969a251ac29c784a66190b25b7e7060294b69e5b8de374ce387b1cd5

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

class EventOptions
  MAX_PROPERTIES_SIZE = 10

  def initialize(event_type, user_id, user_traits, user_name, email, phone, created_at, context, properties, timestamp)
    traits = UserTraits(user_name)
    if user_name && email && phone && created_at
      traits = UserTraits(user_name, email, phone, created_at)
    elsif user_name && email && phone
      traits = UserTraits(user_name, email, phone)
    elsif user_name && email
      traits = UserTraits(user_name, email)
    end

    @event_options = EventOptions(event_type)
    @event_options.user_id = user_id
    @event_options.user_traits = user_traits if user_traits
    @event_options.user_traits = traits
    @event_options.context = context
    @event_options.properties = properties
    @event_options.timestamp = timestamp
  end

  def build
    if !@event_options.properties.nil? && @event_options.properties.length > MAX_PROPERTIES_SIZE
      raise SecureNativeInvalidOptionsError('You can have only up to {} custom properties', MAX_PROPERTIES_SIZE)
    end

    @event_options
  end
end

Version data entries

6 entries across 4 versions & 1 rubygems

Version Path
securenative-0.1.22 out/production/securenative-ruby/event_options.rb
securenative-0.1.21 out/production/securenative-ruby/event_options.rb
securenative-0.1.20 lib/event_options.rb
securenative-0.1.20 out/production/securenative-ruby/event_options.rb
securenative-0.1.18 lib/event_options.rb
securenative-0.1.18 out/production/securenative-ruby/event_options.rb