class AmplitudeAPI::Identification

AmplitudeAPI::Identification

Attributes

device_id[RW]

@!attribute [ rw ] device_id

@return [ String ] the device_id to be sent to Amplitude
user_id[R]

@!attribute [ rw ] user_id

@return [ String ] the user_id to be sent to Amplitude
user_properties[RW]

@!attribute [ rw ] user_properties

@return [ String ] the user_properties to be attached to the Amplitude Identify

Public Class Methods

new(user_id: "", device_id: nil, user_properties: {}) click to toggle source

Create a new Identification

@param [ String ] user_id a user_id to associate with the identification @param [ String ] device_id a device_id to associate with the identification @param [ Hash ] user_properties various properties to attach to the user identification

# File lib/amplitude_api/identification.rb, line 21
def initialize(user_id: "", device_id: nil, user_properties: {})
  self.user_id = user_id
  self.device_id = device_id if device_id
  self.user_properties = user_properties
end

Public Instance Methods

==(other) click to toggle source

@return [ true, false ]

Compares to_hash for equality

# File lib/amplitude_api/identification.rb, line 49
def ==(other)
  if other.respond_to?(:to_hash)
    to_hash == other.to_hash
  else
    false
  end
end
to_hash() click to toggle source

@return [ Hash ] A serialized Event

Used for serialization and comparison

# File lib/amplitude_api/identification.rb, line 39
def to_hash
  {
    user_id: user_id,
    user_properties: user_properties
  }.tap { |hsh| hsh[:device_id] = device_id if device_id }
end
user_id=(value) click to toggle source
# File lib/amplitude_api/identification.rb, line 27
def user_id=(value)
  @user_id =
    if value.respond_to?(:id)
      value.id
    else
      value || AmplitudeAPI::USER_WITH_NO_ACCOUNT
    end
end