Module: Resend::Contacts
- Defined in:
- lib/resend/contacts.rb
Overview
Contacts api wrapper
Class Method Summary collapse
- .create(params) ⇒ Object
-
.get(audience_id, id) ⇒ Object
Retrieves a contact from an audience.
-
.list(audience_id) ⇒ Object
List contacts in an audience.
-
.remove(audience_id, contact_id) ⇒ Object
Remove a contact from an audience.
-
.update(params) ⇒ Object
Update a contact.
Class Method Details
.create(params) ⇒ Object
8 9 10 11 |
# File 'lib/resend/contacts.rb', line 8 def create(params) path = "audiences/#{params[:audience_id]}/contacts" Resend::Request.new(path, params, "post").perform end |
.get(audience_id, id) ⇒ Object
Retrieves a contact from an audience
20 21 22 23 |
# File 'lib/resend/contacts.rb', line 20 def get(audience_id, id) path = "audiences/#{audience_id}/contacts/#{id}" Resend::Request.new(path, {}, "get").perform end |
.list(audience_id) ⇒ Object
List contacts in an audience
30 31 32 33 |
# File 'lib/resend/contacts.rb', line 30 def list(audience_id) path = "audiences/#{audience_id}/contacts" Resend::Request.new(path, {}, "get").perform end |
.remove(audience_id, contact_id) ⇒ Object
Remove a contact from an audience
see also: resend.com/docs/api-reference/contacts/delete-contact
42 43 44 45 |
# File 'lib/resend/contacts.rb', line 42 def remove(audience_id, contact_id) path = "audiences/#{audience_id}/contacts/#{contact_id}" Resend::Request.new(path, {}, "delete").perform end |
.update(params) ⇒ Object
Update a contact
52 53 54 55 56 57 |
# File 'lib/resend/contacts.rb', line 52 def update(params) raise ArgumentError, "id or email is required" if params[:id].nil? && params[:email].nil? path = "audiences/#{params[:audience_id]}/contacts/#{params[:id] || params[:email]}" Resend::Request.new(path, params, "patch").perform end |