Skip to content

Latest commit

 

History

History
494 lines (347 loc) · 35.1 KB

README.md

File metadata and controls

494 lines (347 loc) · 35.1 KB

PolarAdvertisements

(users.advertisements)

Overview

Available Operations

  • list - List Advertisements
  • create - Create Advertisement
  • get - Get Advertisement
  • update - Update Advertisement
  • delete - Delete Advertisement
  • enable - Enable Advertisement

list

List advertisement campaigns.

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.users.advertisements.list({});
  
  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { usersAdvertisementsList } from "@polar-sh/sdk/funcs/usersAdvertisementsList.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await usersAdvertisementsList(polar, {});

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

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

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

Errors

Error Object Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4xx-5xx /

create

Create an advertisement campaign.

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.users.advertisements.create({
    imageUrl: "http://limp-pastry.org",
    text: "<value>",
    linkUrl: "http://flashy-cartload.net",
  });
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { usersAdvertisementsCreate } from "@polar-sh/sdk/funcs/usersAdvertisementsCreate.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await usersAdvertisementsCreate(polar, {
    imageUrl: "http://limp-pastry.org",
    text: "<value>",
    linkUrl: "http://flashy-cartload.net",
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request components.UserAdvertisementCampaignCreate ✔️ 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.UserAdvertisementCampaign>

Errors

Error Object Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4xx-5xx /

get

Get an advertisement campaign by ID.

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.users.advertisements.get({
    id: "<value>",
  });
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { usersAdvertisementsGet } from "@polar-sh/sdk/funcs/usersAdvertisementsGet.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await usersAdvertisementsGet(polar, {
    id: "<value>",
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

Error Object Status Code Content Type
errors.ResourceNotFound 404 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4xx-5xx /

update

Update an advertisement campaign.

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.users.advertisements.update({
    id: "<value>",
    userAdvertisementCampaignUpdate: {},
  });
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { usersAdvertisementsUpdate } from "@polar-sh/sdk/funcs/usersAdvertisementsUpdate.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await usersAdvertisementsUpdate(polar, {
    id: "<value>",
    userAdvertisementCampaignUpdate: {},
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

Error Object Status Code Content Type
errors.ResourceNotFound 404 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4xx-5xx /

delete

Delete an advertisement campaign.

It'll be automatically disabled on all granted benefits.

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.users.advertisements.delete({
    id: "<value>",
  });
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { usersAdvertisementsDelete } from "@polar-sh/sdk/funcs/usersAdvertisementsDelete.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await usersAdvertisementsDelete(polar, {
    id: "<value>",
  });

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

  const { value: result } = res;

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

run();

Parameters

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

Errors

Error Object Status Code Content Type
errors.ResourceNotFound 404 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4xx-5xx /

enable

Enable an advertisement campaign on a granted benefit.

Example Usage

import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  await polar.users.advertisements.enable({
    id: "<value>",
    userAdvertisementCampaignEnable: {
      benefitId: "<value>",
    },
  });
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { usersAdvertisementsEnable } from "@polar-sh/sdk/funcs/usersAdvertisementsEnable.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const res = await usersAdvertisementsEnable(polar, {
    id: "<value>",
    userAdvertisementCampaignEnable: {
      benefitId: "<value>",
    },
  });

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

  const { value: result } = res;

  
}

run();

Parameters

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

Errors

Error Object Status Code Content Type
errors.ResourceNotFound 404 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4xx-5xx /