Class: RIQ::Event

Inherits:
RIQObject show all
Defined in:
lib/riq/event.rb

Overview

Events represent interactions involving a Contact associated with a List Item.

Instance Attribute Summary collapse

Attributes inherited from RIQObject

#id, #modified_date

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RIQObject

#delete, #initialize, #payload

Constructor Details

This class inherits a constructor from RIQ::RIQObject

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



8
9
10
# File 'lib/riq/event.rb', line 8

def body
  @body
end

#subjectObject

Returns the value of attribute subject.



7
8
9
# File 'lib/riq/event.rb', line 7

def subject
  @subject
end

Class Method Details

.nodeString

Returns endpoint.

Returns:

  • (String)

    endpoint



17
18
19
# File 'lib/riq/event.rb', line 17

def self.node
  "events"
end

Instance Method Details

#add_participant(type, value) ⇒ Object

Parameters:

  • type (Symbol)

    One of :email or :phone

  • value (String)

    An email or phone number for the contact

Raises:



32
33
34
35
# File 'lib/riq/event.rb', line 32

def add_participant(type, value)
  raise RIQError, 'Type must be :email or :phone' unless [:email, :phone].include?(type)
  @participant_ids << {type: type, value: value}
end

#dataHash

Returns all relevant stored data.

Returns:

  • (Hash)

    all relevant stored data



22
23
24
25
26
27
28
# File 'lib/riq/event.rb', line 22

def data
  {
    subject: @subject,
    body: @body,
    participant_ids: @participant_ids
  }
end

#nodeString

Returns endpoint.

Returns:

  • (String)

    endpoint



12
13
14
# File 'lib/riq/event.rb', line 12

def node
  self.class.node
end

#participant_idsArray

Returns Immutable copy of participant_ids.

Returns:

  • (Array)

    Immutable copy of participant_ids



38
39
40
# File 'lib/riq/event.rb', line 38

def participant_ids
  @participant_ids.dup
end

#saveHash

Returns Success message, if successful.

Returns:

  • (Hash)

    Success message, if successful.



43
44
45
46
47
# File 'lib/riq/event.rb', line 43

def save
  # there are no options to pass for event save
  @client.put(node, payload, options: nil)
  {status: 204, message: 'No Content'}
end