Skip to content

Latest commit

 

History

History
421 lines (303 loc) · 31.8 KB

README.md

File metadata and controls

421 lines (303 loc) · 31.8 KB

Partners

(partners)

Overview

Available Operations

create

Create a new partner for a program. If partner exists, automatically enrolls them.

Example Usage

import { Dub } from "dub";

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

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

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

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { partnersCreate } from "dub/funcs/partnersCreate.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 partnersCreate(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.CreatePartnerRequestBody ✔️ 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.CreatePartnerResponseBody>

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 */*

createLink

Create a new link for a partner that is enrolled in your program.

Example Usage

import { Dub } from "dub";

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

async function run() {
  const result = await dub.partners.createLink();

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

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { partnersCreateLink } from "dub/funcs/partnersCreateLink.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 partnersCreateLink(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.CreatePartnerLinkRequestBody ✔️ 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.LinkSchema>

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 */*

upsertLink

Upsert a link for a partner that is enrolled in your program. If a link with the same URL already exists, return it (or update it if there are any changes). Otherwise, a new link will be created.

Example Usage

import { Dub } from "dub";

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

async function run() {
  const result = await dub.partners.upsertLink();

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

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { partnersUpsertLink } from "dub/funcs/partnersUpsertLink.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 partnersUpsertLink(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.UpsertPartnerLinkRequestBody ✔️ 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.LinkSchema>

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 */*

analytics

Retrieve analytics for a partner within a program. The response type vary based on the groupBy query parameter.

Example Usage

import { Dub } from "dub";

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

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

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

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { partnersAnalytics } from "dub/funcs/partnersAnalytics.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 partnersAnalytics(dub, {
    programId: "<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.RetrievePartnerAnalyticsRequest ✔️ 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.RetrievePartnerAnalyticsResponseBody>

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 */*

updateSale

Update an existing sale amount. This is useful for handling refunds (partial or full) or fraudulent sales.

Example Usage

import { Dub } from "dub";

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

async function run() {
  const result = await dub.partners.updateSale();

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

run();

Standalone function

The standalone function version of this method:

import { DubCore } from "dub/core.js";
import { partnersUpdateSale } from "dub/funcs/partnersUpdateSale.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 partnersUpdateSale(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.UpdatePartnerSaleRequestBody ✔️ 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.UpdatePartnerSaleResponseBody>

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 */*