Module: Resend::Contacts::Segments
- Defined in:
- lib/resend/contacts/segments.rb
Overview
Contact Segments api wrapper
Class Method Summary collapse
-
.add(params) ⇒ Object
Add a contact to a segment.
-
.list(params) ⇒ Object
List all segments for a contact.
-
.remove(params) ⇒ Object
Remove a contact from a segment.
Class Method Details
.add(params) ⇒ Object
Add a contact to a segment
resend.com/docs/api-reference/contacts/add-contact-to-segment
37 38 39 40 41 42 43 44 |
# File 'lib/resend/contacts/segments.rb', line 37 def add(params) raise ArgumentError, "contact_id or email is required" if params[:contact_id].nil? && params[:email].nil? raise ArgumentError, "segment_id is required" if params[:segment_id].nil? identifier = params[:contact_id] || params[:email] path = "contacts/#{identifier}/segments/#{params[:segment_id]}" Resend::Request.new(path, {}, "post").perform end |
.list(params) ⇒ Object
List all segments for a contact
resend.com/docs/api-reference/contacts/list-contact-segments
19 20 21 22 23 24 25 26 |
# File 'lib/resend/contacts/segments.rb', line 19 def list(params) raise ArgumentError, "contact_id or email is required" if params[:contact_id].nil? && params[:email].nil? identifier = params[:contact_id] || params[:email] base_path = "contacts/#{identifier}/segments" path = Resend::PaginationHelper.build_paginated_path(base_path, params) Resend::Request.new(path, {}, "get").perform end |
.remove(params) ⇒ Object
Remove a contact from a segment
resend.com/docs/api-reference/contacts/remove-contact-from-segment
55 56 57 58 59 60 61 62 |
# File 'lib/resend/contacts/segments.rb', line 55 def remove(params) raise ArgumentError, "contact_id or email is required" if params[:contact_id].nil? && params[:email].nil? raise ArgumentError, "segment_id is required" if params[:segment_id].nil? identifier = params[:contact_id] || params[:email] path = "contacts/#{identifier}/segments/#{params[:segment_id]}" Resend::Request.new(path, {}, "delete").perform end |