Module: Millionsend::Contacts::Batch
- Defined in:
- lib/millionsend/contacts.rb
Overview
Bulk contact creation and deletion — MillionSend extensions (Resend imports via CSV and deletes one at a time).
Class Method Summary collapse
-
.create(list, options = {}) ⇒ Object
POST /contacts/batch with a bare array of up to 1000 create payloads.
-
.get(addresses, options = {}) ⇒ Object
POST /contacts/batch/get — up to 1000 contacts by id or email (bare values or addressing hashes, like Contacts.get) in one request, one call against the rate limit.
-
.remove(params) ⇒ Object
POST /contacts/batch/remove — { ids: [...] } or { emails: [...] } (exactly one, up to 1000), plus erase: true to also scrub each address from email history, event payloads and API logs, as Contacts.remove does.
Class Method Details
.create(list, options = {}) ⇒ Object
POST /contacts/batch with a bare array of up to 1000 create payloads. Options (flat or under options:): on_conflict ("error" default, "skip", "upsert") for emails that already belong to a contact, batch_validation ("strict" default, "permissive" writes the valid subset and lists failures under errors), idempotency_key. Returns { data: [{ index:, id:, status: }], counts: ..., errors: [...] }.
107 108 109 110 111 112 113 114 |
# File 'lib/millionsend/contacts.rb', line 107 def create(list, = {}) = [:options] if .is_a?(Hash) && .key?(:options) Millionsend::Request.new( method: :post, path: "/contacts/batch", body: list, query: { on_conflict: [:on_conflict] }, **Millionsend::Util.() ).perform end |
.get(addresses, options = {}) ⇒ Object
POST /contacts/batch/get — up to 1000 contacts by id or email (bare values or addressing hashes, like Contacts.get) in one request, one call against the rate limit. Returns { data: [...] } in request order plus missing: [{ index:, id: | email: }] for the entries that matched nobody — those never fail the call. include: ["properties", "topics"] attaches the same extras as Contacts.list.
122 123 124 125 |
# File 'lib/millionsend/contacts.rb', line 122 def get(addresses, = {}) body = { contacts: addresses.map { |a| Millionsend::Contacts.address(a) }, include: [:include] } Millionsend::Request.new(method: :post, path: "/contacts/batch/get", body: body.compact).perform end |
.remove(params) ⇒ Object
POST /contacts/batch/remove — { ids: [...] } or { emails: [...] } (exactly one, up to 1000), plus erase: true to also scrub each address from email history, event payloads and API logs, as Contacts.remove does. Returns { data: [{ object:, contact:, deleted: true }] } listing only the rows actually deleted; unknown ids or addresses are skipped.
133 134 135 |
# File 'lib/millionsend/contacts.rb', line 133 def remove(params) Millionsend::Request.new(method: :post, path: "/contacts/batch/remove", body: params).perform end |