Skip to content

Latest commit

 

History

History
421 lines (303 loc) · 31.3 KB

README.md

File metadata and controls

421 lines (303 loc) · 31.3 KB

Customers

(customers)

Overview

Available Operations

  • list - Retrieve a list of customers
  • create - Create a customer
  • get - Retrieve a customer
  • update - Update a customer
  • delete - Delete a customer

list

Retrieve a list of customers for the authenticated workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.customers.list();

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { customersList } from "dub/funcs/customersList.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await customersList(dub);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
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<operations.ResponseBody[]>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.Conflict 409 application/json
errors.InviteExpired 410 application/json
errors.UnprocessableEntity 422 application/json
errors.RateLimitExceeded 429 application/json
errors.InternalServerError 500 application/json
errors.SDKError 4XX, 5XX */*

create

Create a customer for the authenticated workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.customers.create();

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { customersCreate } from "dub/funcs/customersCreate.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await customersCreate(dub);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.CreateCustomerRequestBody ✔️ 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<operations.CreateCustomerResponseBody>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.Conflict 409 application/json
errors.InviteExpired 410 application/json
errors.UnprocessableEntity 422 application/json
errors.RateLimitExceeded 429 application/json
errors.InternalServerError 500 application/json
errors.SDKError 4XX, 5XX */*

get

Retrieve a customer by ID for the authenticated workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.customers.get({
    id: "<id>",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { customersGet } from "dub/funcs/customersGet.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await customersGet(dub, {
    id: "<id>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.GetCustomerRequest ✔️ 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<operations.GetCustomerResponseBody>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.Conflict 409 application/json
errors.InviteExpired 410 application/json
errors.UnprocessableEntity 422 application/json
errors.RateLimitExceeded 429 application/json
errors.InternalServerError 500 application/json
errors.SDKError 4XX, 5XX */*

update

Update a customer for the authenticated workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.customers.update("<id>");

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { customersUpdate } from "dub/funcs/customersUpdate.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await customersUpdate(dub, "<id>");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
id string ✔️ The unique identifier of the customer in Dub.
requestBody operations.UpdateCustomerRequestBody 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<operations.UpdateCustomerResponseBody>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.Conflict 409 application/json
errors.InviteExpired 410 application/json
errors.UnprocessableEntity 422 application/json
errors.RateLimitExceeded 429 application/json
errors.InternalServerError 500 application/json
errors.SDKError 4XX, 5XX */*

delete

Delete a customer from a workspace.

Example Usage

import { Dub } from "dub";

const dub = new Dub({
  token: "DUB_API_KEY",
});

async function run() {
  const result = await dub.customers.delete("<id>");

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { customersDelete } from "dub/funcs/customersDelete.js";

// Use `DubCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const dub = new DubCore({
  token: "DUB_API_KEY",
});

async function run() {
  const res = await customersDelete(dub, "<id>");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
id string ✔️ The unique identifier of the customer in Dub.
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<operations.DeleteCustomerResponseBody>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.Conflict 409 application/json
errors.InviteExpired 410 application/json
errors.UnprocessableEntity 422 application/json
errors.RateLimitExceeded 429 application/json
errors.InternalServerError 500 application/json
errors.SDKError 4XX, 5XX */*