Class: LoopsSdk::Contacts

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

Class Method Summary collapse

Class Method Details

.create(email:, properties: {}, mailing_lists: {}) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/loops_sdk/contacts.rb', line 6

def create(email:, properties: {}, mailing_lists: {})
  contact_data = {
    email: email,
    mailingLists: mailing_lists
  }.merge(properties)
  make_request(:post, "v1/contacts/create", {}, contact_data)
end

.delete(email: nil, user_id: nil) ⇒ Object

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
# File 'lib/loops_sdk/contacts.rb', line 30

def delete(email: nil, user_id: nil)
  raise ArgumentError, "Only one parameter is permitted." if email && user_id
  raise ArgumentError, "You must provide an email or user_id value." if email.nil? && user_id.nil?

  body = email ? { email: email } : { userId: user_id }
  make_request(:post, "v1/contacts/delete", {}, body)
end

.find(email: nil, user_id: nil) ⇒ Object

Raises:

  • (ArgumentError)


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

def find(email: nil, user_id: nil)
  raise ArgumentError, "Only one parameter is permitted." if email && user_id
  raise ArgumentError, "You must provide an email or user_id value." if email.nil? && user_id.nil?

  params = email ? { email: email } : { userId: user_id }
  make_request(:get, "v1/contacts/find", params)
end

.update(email:, properties: {}, mailing_lists: {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/loops_sdk/contacts.rb', line 14

def update(email:, properties: {}, mailing_lists: {})
  contact_data = {
    email: email,
    mailingLists: mailing_lists
  }.merge(properties)
  make_request(:put, "v1/contacts/update", {}, contact_data)
end