Class: Emarsys::ContactList

Inherits:
DataObject show all
Defined in:
lib/emarsys/data_objects/contact_list.rb

Overview

Methods for the ContactList API

Class Method Summary collapse

Methods inherited from DataObject

get, parameterize_params, post, put, #request

Class Method Details

.add_contacts(id, key_id:, external_ids: [], account: nil) ⇒ Object

Add a contacts to a specific contact list

This cannot be an instance method, because the API does not allow to retrieve a single resource. How crappy is that?



45
46
47
# File 'lib/emarsys/data_objects/contact_list.rb', line 45

def add_contacts(id, key_id:, external_ids: [], account: nil)
  post , "contactlist/#{id}/add", {'key_id' => key_id, 'external_ids' => external_ids}
end

.collection(account: nil) ⇒ Hash

List contact lists

Examples:

Emarsys::ContactList.collection

Returns:

  • (Hash)

    List of contact_lists



15
16
17
# File 'lib/emarsys/data_objects/contact_list.rb', line 15

def collection(account: nil)
  get , 'contactlist', {}
end

.create(account: nil, **params) ⇒ Hash

Returns internal id of the contact list.

Examples:

Emarsys::ContactList.create(key_id: "3", name: 'Test-Liste', description: 'Something')

Returns:

  • (Hash)

    internal id of the contact list



28
29
30
# File 'lib/emarsys/data_objects/contact_list.rb', line 28

def create(account: nil, **params)
  post , "contactlist", params
end

.delete(id, account: nil) ⇒ Object

Examples:

Emarsys::ContactList.delete(751283429)


38
39
40
# File 'lib/emarsys/data_objects/contact_list.rb', line 38

def delete(id, account: nil)
  post , "contactlist/#{id}/deletelist", {}
end

.remove_contacts(id, key_id:, external_ids: [], account: nil) ⇒ Object

Remove contacts from a specific contact list

This cannot be an instance method, because the API does not allow to retrieve a single resource. How crappy is that?



52
53
54
# File 'lib/emarsys/data_objects/contact_list.rb', line 52

def remove_contacts(id, key_id:, external_ids: [], account: nil)
  post , "contactlist/#{id}/delete", {'key_id' => key_id, 'external_ids' => external_ids}
end