Inttegro.Otp (inttegro v0.2.0)

Copy Markdown View Source

Initiates, verifies, and inspects one-time passcode transactions.

OTP delivery and verification are separate steps. Initiation returning successfully means the transaction was accepted, not that the recipient received or verified the code. Keep the returned transaction ID and submit the user-provided code through verify/3.

Summary

Functions

Generate a one-time password and deliver it by SMS. Store the returned transaction ID and use it with the recipient's submitted code at the verification endpoint. Retry an uncertain initiation with the same idempotency key and body.

Retrieve the delivery, verification, and expiry state of an OTP transaction by ID. The generated token is never returned by this endpoint.

Check the code submitted by the recipient and record the attempt. A completed request returns a pass or fail verdict; retry an uncertain verification with the same idempotency key and body.

Functions

initiate(client, request, options \\ [])

Generate a one-time password and deliver it by SMS. Store the returned transaction ID and use it with the recipient's submitted code at the verification endpoint. Retry an uncertain initiation with the same idempotency key and body.

Parameters

Returns

Returns {:ok, Inttegro.Otp.Transaction.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.Otp.InitiateRequest.new!(request_attributes)

case Inttegro.Otp.initiate(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end

lookup(client, request, options \\ [])

Retrieve the delivery, verification, and expiry state of an OTP transaction by ID. The generated token is never returned by this endpoint.

Parameters

Returns

Returns {:ok, Inttegro.Otp.Transaction.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.Otp.LookupRequest.new!(request_attributes)

case Inttegro.Otp.lookup(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end

verify(client, request, options \\ [])

Check the code submitted by the recipient and record the attempt. A completed request returns a pass or fail verdict; retry an uncertain verification with the same idempotency key and body.

Parameters

Returns

Returns {:ok, Inttegro.Otp.Verification.t()} when Inttegro accepts and decodes the operation. Returns {:error, exception} for API, transport, or decoding failures. A successful API response can still describe an asynchronous resource that has not reached its terminal state.

Example

request = Inttegro.Otp.VerifyRequest.new!(request_attributes)

case Inttegro.Otp.verify(client, request) do
  {:ok, result} -> result
  {:error, error} -> {:error, error}
end