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
-
.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
14 15 16 17 |
# File 'lib/resend/contacts.rb', line 14 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
24 25 26 27 |
# File 'lib/resend/contacts.rb', line 24 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
36 37 38 39 |
# File 'lib/resend/contacts.rb', line 36 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
46 47 48 49 50 51 |
# File 'lib/resend/contacts.rb', line 46 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 |