Class: LoopsSdk::Events

Inherits:
Base
  • Object
show all
Defined in:
lib/loops_sdk/events.rb

Class Method Summary collapse

Class Method Details

.send(event_name:, email: nil, user_id: nil, contact_properties: {}, event_properties: {}, mailing_lists: {}) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/loops_sdk/events.rb', line 6

def send(event_name:, email: nil, user_id: nil, contact_properties: {}, event_properties: {}, mailing_lists: {})
  raise ArgumentError, "You must provide an email or user_id value." if email.nil? && user_id.nil?

  event_data = {
    email: email,
    userId: user_id,
    eventName: event_name,
    eventProperties: event_properties.compact,
    mailingLists: mailing_lists.compact
  }.merge(contact_properties)
  make_request(:post, "v1/events/send", {}, event_data)
end