Class: LetMeSendEmail::Resources::Contacts
- Defined in:
- lib/letmesendemail/resources/contacts.rb
Overview
Contacts API operations.
Instance Method Summary collapse
-
#create(email:, first_name: nil, last_name: nil, phone: nil, is_globally_unsubscribed: nil, categories: nil, email_topics: nil) ⇒ Models::Model
Creates a contact.
-
#delete(id) ⇒ Models::Model
Deletes a contact.
-
#get(id) ⇒ Models::Model
Retrieves a contact.
-
#list(per_page: nil, after: nil, before: nil) ⇒ Models::Model
Lists one cursor page of contacts.
-
#update(id, first_name: nil, last_name: nil, phone: nil, is_globally_unsubscribed: nil, categories: nil, email_topics: nil, sync_categories: nil, sync_email_topics: nil) ⇒ Models::Model
Updates a contact.
Methods inherited from Base
Constructor Details
This class inherits a constructor from LetMeSendEmail::Resources::Base
Instance Method Details
#create(email:, first_name: nil, last_name: nil, phone: nil, is_globally_unsubscribed: nil, categories: nil, email_topics: nil) ⇒ Models::Model
Creates a contact.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/letmesendemail/resources/contacts.rb', line 9 def create(email:, first_name: nil, last_name: nil, phone: nil, is_globally_unsubscribed: nil, categories: nil, email_topics: nil) body = { email: email } body[:first_name] = first_name if first_name body[:last_name] = last_name if last_name body[:phone] = phone if phone body[:is_globally_unsubscribed] = is_globally_unsubscribed unless is_globally_unsubscribed.nil? body[:categories] = categories if categories body[:email_topics] = email_topics if email_topics @client.request(:post, '/contacts', body: body) end |
#delete(id) ⇒ Models::Model
Deletes a contact.
55 56 57 |
# File 'lib/letmesendemail/resources/contacts.rb', line 55 def delete(id) @client.request(:delete, path_for('contacts', id)) end |
#get(id) ⇒ Models::Model
Retrieves a contact.
30 31 32 |
# File 'lib/letmesendemail/resources/contacts.rb', line 30 def get(id) @client.request(:get, path_for('contacts', id)) end |
#list(per_page: nil, after: nil, before: nil) ⇒ Models::Model
Lists one cursor page of contacts.
23 24 25 |
# File 'lib/letmesendemail/resources/contacts.rb', line 23 def list(per_page: nil, after: nil, before: nil) @client.request(:get, list_path('contacts', per_page: per_page, after: after, before: before)) end |
#update(id, first_name: nil, last_name: nil, phone: nil, is_globally_unsubscribed: nil, categories: nil, email_topics: nil, sync_categories: nil, sync_email_topics: nil) ⇒ Models::Model
Updates a contact.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/letmesendemail/resources/contacts.rb', line 37 def update(id, first_name: nil, last_name: nil, phone: nil, is_globally_unsubscribed: nil, categories: nil, email_topics: nil, sync_categories: nil, sync_email_topics: nil) body = {} body[:first_name] = first_name if first_name body[:last_name] = last_name if last_name body[:phone] = phone if phone body[:is_globally_unsubscribed] = is_globally_unsubscribed unless is_globally_unsubscribed.nil? body[:categories] = categories if categories body[:email_topics] = email_topics if email_topics body[:sync_categories] = sync_categories unless sync_categories.nil? body[:sync_email_topics] = sync_email_topics unless sync_email_topics.nil? @client.request(:put, path_for('contacts', id), body: body) end |