perspectapi-ts-sdk
Classes
CollectionsV2Client
Class: CollectionsV2Client
Extends
BaseV2Client
Constructors
Constructor
new CollectionsV2Client(
http,basePath,cache?):CollectionsV2Client
Parameters
http
HttpClient
basePath
string
cache?
CacheManager
Returns
CollectionsV2Client
Inherited from
BaseV2Client.constructor
Properties
basePath
protectedbasePath:string
Inherited from
BaseV2Client.basePath
cache?
protectedoptionalcache?:CacheManager
Inherited from
BaseV2Client.cache
http
protectedhttp:HttpClient
Inherited from
BaseV2Client.http
Methods
addItem()
addItem(
siteName,collectionId,data):Promise<V2CollectionItem>
Parameters
siteName
string
collectionId
string
data
max_quantity?
number | null
position?
number
product_id
string
Returns
Promise<V2CollectionItem>
buildPath()
protectedbuildPath(endpoint):string
Parameters
endpoint
string
Returns
string
Inherited from
BaseV2Client.buildPath
create()
create(
siteName,data):Promise<V2Collection>
Parameters
siteName
string
data
V2CollectionCreateParams
Returns
Promise<V2Collection>
del()
del(
siteName,id):Promise<V2Deleted>
Parameters
siteName
string
id
string
Returns
Promise<V2Deleted>
deleteOne()
protecteddeleteOne(path):Promise<V2Deleted>
DELETE a resource.
Parameters
path
string
Returns
Promise<V2Deleted>
Inherited from
BaseV2Client.deleteOne
get()
get(
siteName,id):Promise<V2Collection>
Parameters
siteName
string
id
string
Returns
Promise<V2Collection>
getCurrent()
getCurrent(
siteName):Promise<V2Collection|null>
Parameters
siteName
string
Returns
Promise<V2Collection | null>
getList()
protectedgetList<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()
protectedgetOne<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()
protectedinvalidateCache(options):Promise<void>
Invalidate cache entries by keys or tags.
Parameters
options
CacheInvalidateOptions
Returns
Promise<void>
Inherited from
BaseV2Client.invalidateCache
list()
list(
siteName,params?):Promise<V2List<V2Collection>>
Parameters
siteName
string
params?
V2PaginationParams
Returns
Promise<V2List<V2Collection>>
listAutoPaginate()
protectedlistAutoPaginate<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
listItems()
listItems(
siteName,collectionId):Promise<V2List<V2CollectionItem>>
Parameters
siteName
string
collectionId
string
Returns
Promise<V2List<V2CollectionItem>>
patchOne()
protectedpatchOne<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()
protectedpost<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()
protectedputOne<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
removeItem()
removeItem(
siteName,collectionId,itemId):Promise<V2Deleted>
Parameters
siteName
string
collectionId
string
itemId
string
Returns
Promise<V2Deleted>
sitePath()
protectedsitePath(siteName,resource,suffix?):string
Parameters
siteName
string
resource
string
suffix?
string = ''
Returns
string
Inherited from
BaseV2Client.sitePath
update()
update(
siteName,id,data):Promise<V2Collection>
Parameters
siteName
string
id
string
data
V2CollectionUpdateParams
Returns
Promise<V2Collection>