Skip to content

Latest commit

 

History

History
403 lines (284 loc) · 28.5 KB

README.md

File metadata and controls

403 lines (284 loc) · 28.5 KB

Otp

(otp)

Overview

Send OTP codes to your users using their phone numbers.

Available Operations

check

Check a code

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<components.CreateCheckResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 400 application/json
errors.SDKError 4XX, 5XX */*

createAuthentication

Send a code

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<components.CreateAuthenticationResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 400 application/json
errors.SDKError 4XX, 5XX */*

feedback

Send feedback

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<components.FeedbackResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 400 application/json
errors.SDKError 4XX, 5XX */*

getAuthenticationStatus

Get authentication status

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<components.AuthenticationStatusResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 400 application/json
errors.SDKError 4XX, 5XX */*

retry

Perform a retry

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<components.RetryAuthenticationResponse>

Errors

Error Type Status Code Content Type
errors.ErrorResponse 400 application/json
errors.SDKError 4XX, 5XX */*