(otp)
Send OTP codes to your users using their phone numbers.
- check - Check a code
- createAuthentication - Send a code
- feedback - Send feedback
- getAuthenticationStatus - Get authentication status
- retry - Perform a retry
Check a code
import { Ding } from "@ding-live/ding";
const ding = new Ding({
apiKey: "YOUR_API_KEY",
});
async function run() {
const result = await ding.otp.check({
authenticationUuid: "e0e7b0e9-739d-424b-922f-1c2cb48ab077",
checkCode: "123456",
customerUuid: "8f1196d5-806e-4b71-9b24-5f96ec052808",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { DingCore } from "@ding-live/ding/core.js";
import { otpCheck } from "@ding-live/ding/funcs/otpCheck.js";
// Use `DingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const ding = new DingCore({
apiKey: "YOUR_API_KEY",
});
async function run() {
const res = await otpCheck(ding, {
authenticationUuid: "e0e7b0e9-739d-424b-922f-1c2cb48ab077",
checkCode: "123456",
customerUuid: "8f1196d5-806e-4b71-9b24-5f96ec052808",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
components.CreateCheckRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.CreateCheckResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorResponse | 400 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Send a code
import { Ding } from "@ding-live/ding";
const ding = new Ding({
apiKey: "YOUR_API_KEY",
});
async function run() {
const result = await ding.otp.createAuthentication({
customerUuid: "c9f826e0-deca-41ec-871f-ecd6e8efeb46",
locale: "fr-FR",
phoneNumber: "+1234567890",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { DingCore } from "@ding-live/ding/core.js";
import { otpCreateAuthentication } from "@ding-live/ding/funcs/otpCreateAuthentication.js";
// Use `DingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const ding = new DingCore({
apiKey: "YOUR_API_KEY",
});
async function run() {
const res = await otpCreateAuthentication(ding, {
customerUuid: "c9f826e0-deca-41ec-871f-ecd6e8efeb46",
locale: "fr-FR",
phoneNumber: "+1234567890",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
components.CreateAuthenticationRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.CreateAuthenticationResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorResponse | 400 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Send feedback
import { Ding } from "@ding-live/ding";
const ding = new Ding({
apiKey: "YOUR_API_KEY",
});
async function run() {
const result = await ding.otp.feedback({
customerUuid: "c0c405fa-6bcb-4094-9430-7d6e2428ff23",
phoneNumber: "+1234567890",
status: "onboarded",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { DingCore } from "@ding-live/ding/core.js";
import { otpFeedback } from "@ding-live/ding/funcs/otpFeedback.js";
// Use `DingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const ding = new DingCore({
apiKey: "YOUR_API_KEY",
});
async function run() {
const res = await otpFeedback(ding, {
customerUuid: "c0c405fa-6bcb-4094-9430-7d6e2428ff23",
phoneNumber: "+1234567890",
status: "onboarded",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
components.FeedbackRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.FeedbackResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorResponse | 400 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Get authentication status
import { Ding } from "@ding-live/ding";
const ding = new Ding({
apiKey: "YOUR_API_KEY",
});
async function run() {
const result = await ding.otp.getAuthenticationStatus("d8446450-f2fa-4dd9-806b-df5b8c661f23");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { DingCore } from "@ding-live/ding/core.js";
import { otpGetAuthenticationStatus } from "@ding-live/ding/funcs/otpGetAuthenticationStatus.js";
// Use `DingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const ding = new DingCore({
apiKey: "YOUR_API_KEY",
});
async function run() {
const res = await otpGetAuthenticationStatus(ding, "d8446450-f2fa-4dd9-806b-df5b8c661f23");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
authUuid |
string | ✔️ | N/A |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.AuthenticationStatusResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorResponse | 400 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Perform a retry
import { Ding } from "@ding-live/ding";
const ding = new Ding({
apiKey: "YOUR_API_KEY",
});
async function run() {
const result = await ding.otp.retry();
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { DingCore } from "@ding-live/ding/core.js";
import { otpRetry } from "@ding-live/ding/funcs/otpRetry.js";
// Use `DingCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const ding = new DingCore({
apiKey: "YOUR_API_KEY",
});
async function run() {
const res = await otpRetry(ding);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
components.RetryAuthenticationRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.RetryAuthenticationResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorResponse | 400 | application/json |
errors.SDKError | 4XX, 5XX | */* |