Class: Sevk::Resources::Contacts
- Inherits:
-
Base
- Object
- Base
- Sevk::Resources::Contacts
show all
- Defined in:
- lib/sevk/resources/contacts.rb
Instance Attribute Summary
Attributes inherited from Base
#client
Instance Method Summary
collapse
-
#bulk_update(updates) ⇒ Object
-
#create(email:, first_name: nil, last_name: nil, subscribed: nil, metadata: nil) ⇒ Object
-
#delete(id) ⇒ Object
-
#get(id) ⇒ Object
-
#get_events(id) ⇒ Object
-
#import_csv(params) ⇒ Object
-
#list(page: nil, limit: nil, search: nil) ⇒ Object
-
#update(id, first_name: nil, last_name: nil, subscribed: nil, metadata: nil) ⇒ Object
Methods inherited from Base
#initialize
Instance Method Details
#bulk_update(updates) ⇒ Object
39
40
41
|
# File 'lib/sevk/resources/contacts.rb', line 39
def bulk_update(updates)
client.put("/contacts/bulk-update", updates)
end
|
#create(email:, first_name: nil, last_name: nil, subscribed: nil, metadata: nil) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/sevk/resources/contacts.rb', line 17
def create(email:, first_name: nil, last_name: nil, subscribed: nil, metadata: nil)
body = { email: email }
body[:firstName] = first_name if first_name
body[:lastName] = last_name if last_name
body[:subscribed] = subscribed unless subscribed.nil?
body[:metadata] = metadata if metadata
client.post("/contacts", body)
end
|
#delete(id) ⇒ Object
35
36
37
|
# File 'lib/sevk/resources/contacts.rb', line 35
def delete(id)
client.delete("/contacts/#{id}")
end
|
#get(id) ⇒ Object
13
14
15
|
# File 'lib/sevk/resources/contacts.rb', line 13
def get(id)
client.get("/contacts/#{id}")
end
|
#get_events(id) ⇒ Object
47
48
49
|
# File 'lib/sevk/resources/contacts.rb', line 47
def get_events(id)
client.get("/contacts/#{id}/events")
end
|
#import_csv(params) ⇒ Object
43
44
45
|
# File 'lib/sevk/resources/contacts.rb', line 43
def import_csv(params)
client.post("/contacts/import", params)
end
|
#list(page: nil, limit: nil, search: nil) ⇒ Object
8
9
10
11
|
# File 'lib/sevk/resources/contacts.rb', line 8
def list(page: nil, limit: nil, search: nil)
params = { page: page, limit: limit, search: search }
client.get("/contacts#{build_query_string(params)}")
end
|
#update(id, first_name: nil, last_name: nil, subscribed: nil, metadata: nil) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/sevk/resources/contacts.rb', line 26
def update(id, first_name: nil, last_name: nil, subscribed: nil, metadata: nil)
body = {}
body[:firstName] = first_name if first_name
body[:lastName] = last_name if last_name
body[:subscribed] = subscribed unless subscribed.nil?
body[:metadata] = metadata if metadata
client.put("/contacts/#{id}", body)
end
|