Class: Mailfloss::Resources::BatchVerify

Inherits:
Base
  • Object
show all
Defined in:
lib/mailfloss/resources.rb,
sig/resources.rbs

Overview

POST /batch-verify and its sub-resources.

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#encode, #initialize

Constructor Details

This class inherits a constructor from Mailfloss::Resources::Base

Instance Method Details

#cancel(id, idempotency_key: nil) ⇒ Hash

POST /batch-verify/id/cancel

Parameters:

  • id (String)
  • idempotency_key: (String, nil) (defaults to: nil)

Returns:

  • (Hash)

    { success: }



54
55
56
# File 'lib/mailfloss/resources.rb', line 54

def cancel(id, idempotency_key: nil)
  client.request(:post, "/batch-verify/#{encode(id)}/cancel", idempotency_key: idempotency_key)
end

#create(emails:, webhook_url: nil, idempotency_key: nil) ⇒ Hash

POST /batch-verify — submit a batch of emails for verification.

Parameters:

  • emails (Array<String>)
  • webhook_url (String, nil) (defaults to: nil)

    optional completion callback URL

  • idempotency_key (String, nil) (defaults to: nil)

    auto-generated when omitted

Returns:

  • (Hash)

    { id: } — the created batch job id



28
29
30
31
32
# File 'lib/mailfloss/resources.rb', line 28

def create(emails:, webhook_url: nil, idempotency_key: nil)
  body = { emails: emails }
  body[:webhook_url] = webhook_url if webhook_url
  client.request(:post, "/batch-verify", body: body, idempotency_key: idempotency_key)
end

#results(id, per_page: nil, next_cursor: nil) ⇒ Hash

GET /batch-verify/id/results

Parameters:

  • per_page (Integer, nil) (defaults to: nil)
  • next_cursor (String, nil) (defaults to: nil)

    the next query param

  • id (String)
  • per_page: (Integer, nil) (defaults to: nil)
  • next_cursor: (String, nil) (defaults to: nil)

Returns:

  • (Hash)

    { id:, results: [...] }



46
47
48
49
# File 'lib/mailfloss/resources.rb', line 46

def results(id, per_page: nil, next_cursor: nil)
  client.request(:get, "/batch-verify/#{encode(id)}/results",
                 query: { per_page: per_page, next: next_cursor })
end

#status(id) ⇒ Hash

GET /batch-verify/id/status

Parameters:

  • id (String)

Returns:

  • (Hash)

    { status:, progress: }



37
38
39
# File 'lib/mailfloss/resources.rb', line 37

def status(id)
  client.request(:get, "/batch-verify/#{encode(id)}/status")
end