Class: AmplitudeAPI::Identification

Inherits:
Object
  • Object
show all
Defined in:
lib/amplitude_api/identification.rb

Overview

AmplitudeAPI::Identification

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id: '', user_properties: {}) ⇒ Identification

Create a new Identification

Parameters:

  • user_id (String) (defaults to: '')

    a user_id to associate with the identification

  • user_properties (Hash) (defaults to: {})

    various properties to attach to the user identification



15
16
17
18
# File 'lib/amplitude_api/identification.rb', line 15

def initialize(user_id: '', user_properties: {})
  self.user_id = user_id
  self.user_properties = user_properties
end

Instance Attribute Details

#user_idString

Returns the user_id to be sent to Amplitude.

Returns:

  • (String)

    the user_id to be sent to Amplitude



6
7
8
# File 'lib/amplitude_api/identification.rb', line 6

def user_id
  @user_id
end

#user_propertiesString

Returns the user_properties to be attached to the Amplitude Identify.

Returns:

  • (String)

    the user_properties to be attached to the Amplitude Identify



9
10
11
# File 'lib/amplitude_api/identification.rb', line 9

def user_properties
  @user_properties
end

Instance Method Details

#==(other) ⇒ true, false

Compares +to_hash+ for equality

Returns:

  • (true, false)


42
43
44
45
46
47
48
# File 'lib/amplitude_api/identification.rb', line 42

def ==(other)
  if other.respond_to?(:to_hash)
    to_hash == other.to_hash
  else
    false
  end
end

#to_hashHash

Used for serialization and comparison

Returns:

  • (Hash)

    A serialized Event



32
33
34
35
36
37
# File 'lib/amplitude_api/identification.rb', line 32

def to_hash
  {
    user_id: user_id,
    user_properties: user_properties
  }
end