PerspectPerspectDocs
Go to Admin
View as Markdown

perspectapi-ts-sdk

Classes

  • OrdersV2Client

Class: OrdersV2Client

Extends

  • BaseV2Client

Constructors

Constructor

new OrdersV2Client(http, basePath, cache?): OrdersV2Client

Parameters

http

HttpClient

basePath

string

cache?

CacheManager

Returns

OrdersV2Client

Inherited from

BaseV2Client.constructor

Properties

basePath

protected basePath: string

Inherited from

BaseV2Client.basePath

cache?

protected optional cache?: CacheManager

Inherited from

BaseV2Client.cache

http

protected http: HttpClient

Inherited from

BaseV2Client.http

Methods

buildPath()

protected buildPath(endpoint): string

Parameters

endpoint

string

Returns

string

Inherited from

BaseV2Client.buildPath

create()

create(siteName, data): Promise<V2OrderCreateResult>

Create a checkout session via Stripe. Returns the session ID and a checkout_url that the client should redirect to (or open in a new tab).

This replaces the v1 checkout.createCheckoutSession() + getCsrfToken() dance — v2 is API-key-only and requires no CSRF token.

Parameters

siteName

string

data

V2OrderCreateParams

Returns

Promise<V2OrderCreateResult>

deleteOne()

protected deleteOne(path): Promise<V2Deleted>

DELETE a resource.

Parameters

path

string

Returns

Promise<V2Deleted>

Inherited from

BaseV2Client.deleteOne

get()

get(siteName, id, cachePolicy?): Promise<V2Order>

Parameters

siteName

string

id

string

cachePolicy?

CachePolicy

Returns

Promise<V2Order>

getList()

protected getList<T>(path, params?, cachePolicy?): Promise<V2List<T>>

GET a list of resources with cursor pagination, with optional caching.

Type Parameters

T

T

Parameters

path

string

params?

object

cachePolicy?

CachePolicy

Returns

Promise<V2List<T>>

Inherited from

BaseV2Client.getList

getOne()

protected getOne<T>(path, params?, cachePolicy?): Promise<T>

GET a single resource, with optional caching.

Type Parameters

T

T

Parameters

path

string

params?

object

cachePolicy?

CachePolicy

Returns

Promise<T>

Inherited from

BaseV2Client.getOne

invalidateCache()

protected invalidateCache(options): Promise<void>

Invalidate cache entries by keys or tags.

Parameters

options

CacheInvalidateOptions

Returns

Promise<void>

Inherited from

BaseV2Client.invalidateCache

list()

list(siteName, params?, cachePolicy?): Promise<V2List<V2Order>>

Parameters

siteName

string

params?

V2OrderListParams

cachePolicy?

CachePolicy

Returns

Promise<V2List<V2Order>>

listAutoPaginate()

protected listAutoPaginate<T>(path, params?): AsyncGenerator<T, void, unknown>

Auto-paginating async generator. Yields every item across all pages.

Usage: for await (const item of client.listAutoPaginate(path, params)) { ... }

Type Parameters

T

T extends object

Parameters

path

string

params?

object

Returns

AsyncGenerator<T, void, unknown>

Inherited from

BaseV2Client.listAutoPaginate

listAutoPaginated()

listAutoPaginated(siteName, params?): AsyncGenerator<V2Order, void, unknown>

Parameters

siteName

string

params?

Omit<V2OrderListParams, "starting_after" | "ending_before">

Returns

AsyncGenerator<V2Order, void, unknown>

patchOne()

protected patchOne<T>(path, body?): Promise<T>

PATCH to update a resource.

Type Parameters

T

T

Parameters

path

string

body?

unknown

Returns

Promise<T>

Inherited from

BaseV2Client.patchOne

post()

protected post<T>(path, body?): Promise<T>

POST to create a resource.

Type Parameters

T

T

Parameters

path

string

body?

unknown

Returns

Promise<T>

Inherited from

BaseV2Client.post

putOne()

protected putOne<T>(path, body?): Promise<T>

PUT to upsert a resource.

Type Parameters

T

T

Parameters

path

string

body?

unknown

Returns

Promise<T>

Inherited from

BaseV2Client.putOne

sitePath()

protected sitePath(siteName, resource, suffix?): string

Parameters

siteName

string

resource

string

suffix?

string = ''

Returns

string

Inherited from

BaseV2Client.sitePath

updateFulfillment()

updateFulfillment(siteName, id, data): Promise<V2Order>

Update fulfillment status, tracking number, and/or notes on an order.

Parameters

siteName

string

id

string

data

V2OrderFulfillmentUpdate

Returns

Promise<V2Order>