Skip to content

Latest commit

 

History

History
689 lines (501 loc) · 58.9 KB

File metadata and controls

689 lines (501 loc) · 58.9 KB

CustomerPortal.Customers

Overview

Available Operations

get

Get authenticated customer.

Scopes: customer_portal:read customer_portal:write

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.customers.get({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalCustomersGet(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalCustomersGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
security operations.CustomerPortalCustomersGetSecurity ✔️ The security requirements 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.CustomerPortalCustomer>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

update

Update authenticated customer.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.customers.update({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    billingAddress: {
      country: "US",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalCustomersUpdate(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    billingAddress: {
      country: "US",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalCustomersUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.CustomerPortalCustomerUpdate ✔️ The request object to use for the request.
security operations.CustomerPortalCustomersUpdateSecurity ✔️ The security requirements 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.CustomerPortalCustomer>

Errors

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

listPaymentMethods

Get saved payment methods of the authenticated customer.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.customers.listPaymentMethods({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {});

  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 { customerPortalCustomersListPaymentMethods } from "@polar-sh/sdk/funcs/customerPortalCustomersListPaymentMethods.js";

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalCustomersListPaymentMethods(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {});
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("customerPortalCustomersListPaymentMethods failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalCustomersListPaymentMethodsRequest ✔️ The request object to use for the request.
security operations.CustomerPortalCustomersListPaymentMethodsSecurity ✔️ The security requirements 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.CustomerPortalCustomersListPaymentMethodsResponse>

Errors

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

addPaymentMethod

Add a payment method to the authenticated customer.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.customers.addPaymentMethod({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    confirmationTokenId: "<id>",
    setDefault: false,
    returnUrl: "https://yearly-custom.net/",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalCustomersAddPaymentMethod(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    confirmationTokenId: "<id>",
    setDefault: false,
    returnUrl: "https://yearly-custom.net/",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalCustomersAddPaymentMethod failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.CustomerPaymentMethodCreate ✔️ The request object to use for the request.
security operations.CustomerPortalCustomersAddPaymentMethodSecurity ✔️ The security requirements 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.CustomerPaymentMethodCreateResponse>

Errors

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

confirmPaymentMethod

Confirm a payment method for the authenticated customer.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.customers.confirmPaymentMethod({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    setupIntentId: "<id>",
    setDefault: true,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalCustomersConfirmPaymentMethod(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    setupIntentId: "<id>",
    setDefault: true,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalCustomersConfirmPaymentMethod failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.CustomerPaymentMethodConfirm ✔️ The request object to use for the request.
security operations.CustomerPortalCustomersConfirmPaymentMethodSecurity ✔️ The security requirements 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.CustomerPaymentMethodCreateResponse>

Errors

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

deletePaymentMethod

Delete a payment method from the authenticated customer.

Example Usage

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

const polar = new Polar();

async function run() {
  await polar.customerPortal.customers.deletePaymentMethod({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<id>",
  });


}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalCustomersDeletePaymentMethod(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    id: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("customerPortalCustomersDeletePaymentMethod failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalCustomersDeletePaymentMethodRequest ✔️ The request object to use for the request.
security operations.CustomerPortalCustomersDeletePaymentMethodSecurity ✔️ The security requirements 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.PaymentMethodInUseByActiveSubscription 400 application/json
errors.ResourceNotFound 404 application/json
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

requestEmailUpdate

Request an email change for the authenticated customer.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.customers.requestEmailUpdate({
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    email: "Tommie_Larkin78@gmail.com",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalCustomersRequestEmailUpdate(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  }, {
    email: "Tommie_Larkin78@gmail.com",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalCustomersRequestEmailUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.CustomerEmailUpdateRequest ✔️ The request object to use for the request.
security operations.CustomerPortalCustomersRequestEmailUpdateSecurity ✔️ The security requirements 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 Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

checkEmailUpdate

Check if an email change verification token is still valid.

Example Usage

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

const polar = new Polar();

async function run() {
  await polar.customerPortal.customers.checkEmailUpdate({
    token: "<value>",
  });


}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalCustomersCheckEmailUpdate(polar, {
    token: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("customerPortalCustomersCheckEmailUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CustomerPortalCustomersCheckEmailUpdateRequest ✔️ 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 */*

verifyEmailUpdate

Verify an email change using the token from the verification email.

Example Usage

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

const polar = new Polar();

async function run() {
  const result = await polar.customerPortal.customers.verifyEmailUpdate({
    token: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

// Use `PolarCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const polar = new PolarCore();

async function run() {
  const res = await customerPortalCustomersVerifyEmailUpdate(polar, {
    token: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalCustomersVerifyEmailUpdate failed:", res.error);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*