(users.advertisements)
- list - List Advertisements
- create - Create Advertisement
- get - Get Advertisement
- update - Update Advertisement
- delete - Delete Advertisement
- enable - Enable Advertisement
List advertisement campaigns.
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();
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();
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. |
Promise<operations.UsersAdvertisementsListResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.HTTPValidationError | 422 | application/json |
errors.SDKError | 4xx-5xx | / |
Create an advertisement campaign.
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();
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();
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. |
Promise<components.UserAdvertisementCampaign>
Error Object | Status Code | Content Type |
---|---|---|
errors.HTTPValidationError | 422 | application/json |
errors.SDKError | 4xx-5xx | / |
Get an advertisement campaign by ID.
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();
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();
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. |
Promise<components.UserAdvertisementCampaign>
Error Object | Status Code | Content Type |
---|---|---|
errors.ResourceNotFound | 404 | application/json |
errors.HTTPValidationError | 422 | application/json |
errors.SDKError | 4xx-5xx | / |
Update an advertisement campaign.
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();
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();
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. |
Promise<components.UserAdvertisementCampaign>
Error Object | Status Code | Content Type |
---|---|---|
errors.ResourceNotFound | 404 | application/json |
errors.HTTPValidationError | 422 | application/json |
errors.SDKError | 4xx-5xx | / |
Delete an advertisement campaign.
It'll be automatically disabled on all granted benefits.
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();
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();
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. |
Promise<any>
Error Object | Status Code | Content Type |
---|---|---|
errors.ResourceNotFound | 404 | application/json |
errors.HTTPValidationError | 422 | application/json |
errors.SDKError | 4xx-5xx | / |
Enable an advertisement campaign on a granted benefit.
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();
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();
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. |
Promise<void>
Error Object | Status Code | Content Type |
---|---|---|
errors.ResourceNotFound | 404 | application/json |
errors.HTTPValidationError | 422 | application/json |
errors.SDKError | 4xx-5xx | / |