Class: ShopCircle::Orbit::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/shopcircle/orbit/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, name: nil, profile_id: nil, device_id: nil, properties: nil, first_name: nil, last_name: nil, email: nil, avatar: nil) ⇒ Event

Returns a new instance of Event.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/shopcircle/orbit/event.rb', line 10

def initialize(type:, name: nil, profile_id: nil, device_id: nil,
               properties: nil, first_name: nil, last_name: nil,
               email: nil, avatar: nil)
  @type       = type
  @name       = name
  @profile_id = profile_id
  @device_id  = device_id
  @properties = properties
  @first_name = first_name
  @last_name  = last_name
  @email      = email
  @avatar     = avatar
end

Instance Attribute Details

#avatarObject (readonly)

Returns the value of attribute avatar.



6
7
8
# File 'lib/shopcircle/orbit/event.rb', line 6

def avatar
  @avatar
end

#device_idObject (readonly)

Returns the value of attribute device_id.



6
7
8
# File 'lib/shopcircle/orbit/event.rb', line 6

def device_id
  @device_id
end

#emailObject (readonly)

Returns the value of attribute email.



6
7
8
# File 'lib/shopcircle/orbit/event.rb', line 6

def email
  @email
end

#first_nameObject (readonly)

Returns the value of attribute first_name.



6
7
8
# File 'lib/shopcircle/orbit/event.rb', line 6

def first_name
  @first_name
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



6
7
8
# File 'lib/shopcircle/orbit/event.rb', line 6

def last_name
  @last_name
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/shopcircle/orbit/event.rb', line 6

def name
  @name
end

#profile_idObject (readonly)

Returns the value of attribute profile_id.



6
7
8
# File 'lib/shopcircle/orbit/event.rb', line 6

def profile_id
  @profile_id
end

#propertiesObject (readonly)

Returns the value of attribute properties.



6
7
8
# File 'lib/shopcircle/orbit/event.rb', line 6

def properties
  @properties
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/shopcircle/orbit/event.rb', line 6

def type
  @type
end

Instance Method Details

#to_payloadObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/shopcircle/orbit/event.rb', line 24

def to_payload
  payload = {}
  payload[:name]       = @name       if @name
  payload[:profileId]  = @profile_id if @profile_id
  payload[:deviceId]   = @device_id  if @device_id
  payload[:firstName]  = @first_name if @first_name
  payload[:lastName]   = @last_name  if @last_name
  payload[:email]      = @email      if @email
  payload[:avatar]     = @avatar     if @avatar
  payload[:properties] = normalize_keys(@properties) if @properties && !@properties.empty?
  { type: @type, payload: payload }
end