Skip to content

Latest commit

 

History

History
332 lines (240 loc) · 24.6 KB

File metadata and controls

332 lines (240 loc) · 24.6 KB

CustomerPortal.Members

Overview

Available Operations

listMembers

List all members of the customer's team.

Only available to owners and billing managers of team customers.

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.customerPortal.members.listMembers({});

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

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalMembersListMembers } from "@polar-sh/sdk/funcs/customerPortalMembersListMembers.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 customerPortalMembersListMembers(polar, {});
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("customerPortalMembersListMembers failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

addMember

Add a new member to the customer's team.

Only available to owners and billing managers of team customers.

Rules:

  • Cannot add a member with the owner role (there must be exactly one owner)
  • If a member with this email already exists, the existing member is returned

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.customerPortal.members.addMember({
    email: "Domenica.Schamberger@yahoo.com",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalMembersAddMember } from "@polar-sh/sdk/funcs/customerPortalMembersAddMember.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 customerPortalMembersAddMember(polar, {
    email: "Domenica.Schamberger@yahoo.com",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalMembersAddMember failed:", res.error);
  }
}

run();

Parameters

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

Errors

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

removeMember

Remove a member from the team.

Only available to owners and billing managers of team customers.

Rules:

  • Cannot remove yourself
  • Cannot remove the only owner

Example Usage

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

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

async function run() {
  await polar.customerPortal.members.removeMember({
    id: "b61c5e87-cda5-4b14-93ee-71a695f42d9d",
  });


}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalMembersRemoveMember } from "@polar-sh/sdk/funcs/customerPortalMembersRemoveMember.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 customerPortalMembersRemoveMember(polar, {
    id: "b61c5e87-cda5-4b14-93ee-71a695f42d9d",
  });
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("customerPortalMembersRemoveMember failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalMembersRemoveMemberRequest ✔️ 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 Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

updateMember

Update a member's name or role.

Only available to owners and billing managers of team customers.

Rules:

  • Cannot modify your own role (to prevent self-demotion)
  • Customer must have exactly one owner at all times

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.customerPortal.members.updateMember({
    id: "8319ae11-ed5f-4642-81e4-4b40731df195",
    customerPortalMemberUpdate: {
      name: "Jane Doe",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { PolarCore } from "@polar-sh/sdk/core.js";
import { customerPortalMembersUpdateMember } from "@polar-sh/sdk/funcs/customerPortalMembersUpdateMember.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 customerPortalMembersUpdateMember(polar, {
    id: "8319ae11-ed5f-4642-81e4-4b40731df195",
    customerPortalMemberUpdate: {
      name: "Jane Doe",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalMembersUpdateMember failed:", res.error);
  }
}

run();

Parameters

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

Errors

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