PerspectPerspectDocs
Go to Admin
View as Markdown

perspectapi-ts-sdk

Classes

  • SubscriptionsV2Client

Class: SubscriptionsV2Client

Extends

  • BaseV2Client

Constructors

Constructor

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

Parameters

http

HttpClient

basePath

string

cache?

CacheManager

Returns

SubscriptionsV2Client

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

cancelSubscription()

cancelSubscription(siteName, subId, params?): Promise<V2CancelSubscriptionResult>

Cancel a subscription.

Parameters

siteName

string

subId

string

params?

V2SubscriptionCancelParams

Returns

Promise<V2CancelSubscriptionResult>

cancelUserSubscription()

cancelUserSubscription(siteName, userId, subId, params?): Promise<V2CancelSubscriptionResult>

Cancel a user's subscription (admin).

Parameters

siteName

string

userId

string

subId

string

params?

V2SubscriptionCancelParams

Returns

Promise<V2CancelSubscriptionResult>

changeSubscriptionPlan()

changeSubscriptionPlan(siteName, subId, params): Promise<V2SiteUserSubscription>

Change the plan (price) of a subscription.

Parameters

siteName

string

subId

string

params

V2SubscriptionChangePlanParams

Returns

Promise<V2SiteUserSubscription>

deleteOne()

protected deleteOne(path): Promise<V2Deleted>

DELETE a resource.

Parameters

path

string

Returns

Promise<V2Deleted>

Inherited from

BaseV2Client.deleteOne

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

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

listMySubscriptions()

listMySubscriptions(siteName): Promise<V2List<V2SiteUserSubscription>>

List all subscriptions for the authenticated user.

Parameters

siteName

string

Returns

Promise<V2List<V2SiteUserSubscription>>

listUserSubscriptions()

listUserSubscriptions(siteName, userId): Promise<V2List<V2SiteUserSubscription>>

List subscriptions for a specific user (admin).

Parameters

siteName

string

userId

string

Returns

Promise<V2List<V2SiteUserSubscription>>

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

pauseSubscription()

pauseSubscription(siteName, subId, params?): Promise<V2SiteUserSubscription>

Pause a subscription.

Parameters

siteName

string

subId

string

params?

V2SubscriptionPauseParams

Returns

Promise<V2SiteUserSubscription>

pauseUserSubscription()

pauseUserSubscription(siteName, userId, subId, params?): Promise<V2SiteUserSubscription>

Pause a user's subscription (admin).

Parameters

siteName

string

userId

string

subId

string

params?

V2SubscriptionPauseParams

Returns

Promise<V2SiteUserSubscription>

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

resumeSubscription()

resumeSubscription(siteName, subId): Promise<V2SiteUserSubscription>

Resume a paused subscription.

Parameters

siteName

string

subId

string

Returns

Promise<V2SiteUserSubscription>

resumeUserSubscription()

resumeUserSubscription(siteName, userId, subId): Promise<V2SiteUserSubscription>

Resume a user's paused subscription (admin).

Parameters

siteName

string

userId

string

subId

string

Returns

Promise<V2SiteUserSubscription>

sitePath()

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

Parameters

siteName

string

resource

string

suffix?

string = ''

Returns

string

Inherited from

BaseV2Client.sitePath