Class: Telnyx::Resources::EmailBlocks::Import

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/email_blocks/import.rb,
sig/telnyx/resources/email_blocks/import.rbs

Overview

Async CSV import of competitor suppression lists.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Import

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Import.

Parameters:



73
74
75
# File 'lib/telnyx/resources/email_blocks/import.rb', line 73

def initialize(client:)
  @client = client
end

Instance Method Details

#create(file:, block_ttl_days: nil, request_options: {}) ⇒ Telnyx::Models::EmailBlocks::EmailBlockImportResponse

Some parameter documentations has been truncated, see Models::EmailBlocks::ImportCreateParams for more details.

Accepts multipart/form-data with a file field (the CSV) and an optional block_ttl_days (integer >0, default 30). Validates:

  • content ≤ 25 MiB, else 413
  • row count ≤ 250 000, else 413
  • header-only / all-blank / undetectable provider → 400 Returns 202 with the import record (status pending); an Oban worker (EmailBlockImportWorker, max_attempts 3) transitions pending → processing → completed | failed. block_ttl_days applies only to imported manual_block rows; other reasons get expires_at: nil. Provider is auto-detected from the CSV header (sendgrid / mailgun / ses / generic).

Parameters:

  • file (Pathname, StringIO, IO, String, Telnyx::FilePart)

    The CSV file (Plug.Upload). Missing/non-upload → 400.

  • block_ttl_days (Integer)

    TTL for imported manual_block rows; other reasons get expires_at: null. Inva

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/telnyx/resources/email_blocks/import.rb', line 34

def create(params)
  parsed, options = Telnyx::EmailBlocks::ImportCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "email_blocks/import",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: Telnyx::EmailBlocks::EmailBlockImportResponse,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ Telnyx::Models::EmailBlocks::EmailBlockImportResponse

Account-scoped fetch (cross-account → 404; malformed UUID → 404). Nullable fields are omitted until terminal: provider/completed_at when nil; processed_rows/created_count/existing_count/ skipped_count/error_count only when status == completed; errors only when non-empty; failure_reason only on terminal failure.

Parameters:

  • id (String)

    Resource UUID. Malformed UUIDs are treated as not-found (not 400).

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



61
62
63
64
65
66
67
68
# File 'lib/telnyx/resources/email_blocks/import.rb', line 61

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["email_blocks/import/%1$s", id],
    model: Telnyx::EmailBlocks::EmailBlockImportResponse,
    options: params[:request_options]
  )
end