Class: SignalApi::SegmentUser

Inherits:
Object
  • Object
show all
Defined in:
lib/signal_api/segment.rb

Overview

Represents a user to be added to a segment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifying_attribute, user_data = {}) ⇒ SegmentUser

Create a new segment on the Signal platform.

Parameters:

  • identifying_attribute (String)

    The mobile phone or email address of the user

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

    Optional A collection of key/value pairs to store along with this user’s segment record for later use



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/signal_api/segment.rb', line 18

def initialize(identifying_attribute, user_data={})
  if Phone.valid?(identifying_attribute)
    @mobile_phone = identifying_attribute
  elsif EmailAddress.valid?(identifying_attribute)
    @email_address = identifying_attribute
  else
    raise InvalidParameterException.new("identifying_attribute must be a valid mobile phone number or email address")
  end

  @user_data = user_data unless user_data.empty?
end

Instance Attribute Details

#email_addressObject (readonly)

Returns the value of attribute email_address.



11
12
13
# File 'lib/signal_api/segment.rb', line 11

def email_address
  @email_address
end

#mobile_phoneObject (readonly)

Returns the value of attribute mobile_phone.



11
12
13
# File 'lib/signal_api/segment.rb', line 11

def mobile_phone
  @mobile_phone
end

#user_dataObject (readonly)

Returns the value of attribute user_data.



11
12
13
# File 'lib/signal_api/segment.rb', line 11

def user_data
  @user_data
end