Skip to content

Latest commit

 

History

History
150 lines (105 loc) · 11.9 KB

File metadata and controls

150 lines (105 loc) · 11.9 KB

CustomerPortal.CustomerSession

Overview

Available Operations

introspect

Introspect the current session and return its information.

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.customerSession.introspect({
    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 { customerPortalCustomerSessionIntrospect } from "@polar-sh/sdk/funcs/customerPortalCustomerSessionIntrospect.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 customerPortalCustomerSessionIntrospect(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalCustomerSessionIntrospect failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
security operations.CustomerPortalCustomerSessionIntrospectSecurity ✔️ 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.CustomerCustomerSession>

Errors

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

getAuthenticatedUser

Get information about the currently authenticated portal user.

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.customerSession.getAuthenticatedUser({
    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 { customerPortalCustomerSessionGetAuthenticatedUser } from "@polar-sh/sdk/funcs/customerPortalCustomerSessionGetAuthenticatedUser.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 customerPortalCustomerSessionGetAuthenticatedUser(polar, {
    customerSession: process.env["POLAR_CUSTOMER_SESSION"] ?? "",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("customerPortalCustomerSessionGetAuthenticatedUser failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
security operations.CustomerPortalCustomerSessionGetAuthenticatedUserSecurity ✔️ 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.PortalAuthenticatedUser>

Errors

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