Module: Resend::Contacts::Imports
- Defined in:
- lib/resend/contacts/imports.rb
Overview
Contact Imports API wrapper
Class Method Summary collapse
-
.create(params) ⇒ Object
Create a new contact import from a CSV file.
-
.get(id) ⇒ Object
Retrieve a single contact import by ID.
-
.list(params = {}) ⇒ Object
Retrieve a list of contact imports.
Class Method Details
.create(params) ⇒ Object
Create a new contact import from a CSV file.
resend.com/docs/api-reference/contacts/create-contact-import
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/resend/contacts/imports.rb', line 24 def create(params) raise ArgumentError, "Missing required `file` field" if params[:file].nil? # Normalize segments: convert array of IDs to [{id: ...}] format if params[:segments].is_a?(Array) params = params.merge(segments: params[:segments].map { |s| s.is_a?(String) ? { id: s } : s }) end Resend::MultipartRequest.new("contacts/imports", params, "post").perform end |
.get(id) ⇒ Object
Retrieve a single contact import by ID.
41 42 43 44 45 |
# File 'lib/resend/contacts/imports.rb', line 41 def get(id) raise ArgumentError, "Missing required `id` field" if id.nil? || id.empty? Resend::Request.new("contacts/imports/#{id}", {}, "get").perform end |
.list(params = {}) ⇒ Object
Retrieve a list of contact imports.
57 58 59 60 |
# File 'lib/resend/contacts/imports.rb', line 57 def list(params = {}) path = Resend::PaginationHelper.build_paginated_path("contacts/imports", params) Resend::Request.new(path, {}, "get").perform end |