Skip to content

Commit 7ebe1bf

Browse files
committed
feat: support listing of services and datasets associated to a subsciption
1 parent ef7449e commit 7ebe1bf

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nevermined-io/payments",
3-
"version": "0.1.8",
3+
"version": "0.1.9",
44
"description": "Typescript SDK to interact with the Nevermined Payments Protocol",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/payments.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,37 @@ export class Payments {
480480
return response.json()
481481
}
482482

483+
484+
/**
485+
* Get array of services DIDs associated with a subscription.
486+
*
487+
* @param did - The DID of the asset.
488+
* @returns A promise that resolves to the array of services DIDs.
489+
*/
490+
public async getSubscriptionAssociatedServices(subscriptionDid: string) {
491+
const url = new URL(`/api/v1/payments/subscription/services/${subscriptionDid}`, this.environment.backend)
492+
const response = await fetch(url)
493+
if (!response.ok) {
494+
throw Error(response.statusText)
495+
}
496+
return response.json()
497+
}
498+
499+
/**
500+
* Get array of files DIDs associated with a subscription.
501+
*
502+
* @param did - The DID of the asset.
503+
* @returns A promise that resolves to array of files DIDs.
504+
*/
505+
public async getSubscriptionAssociatedFiles(subscriptionDid: string) {
506+
const url = new URL(`/api/v1/payments/subscription/files/${subscriptionDid}`, this.environment.backend)
507+
const response = await fetch(url)
508+
if (!response.ok) {
509+
throw Error(response.statusText)
510+
}
511+
return response.json()
512+
}
513+
483514
/**
484515
* Get the balance of an account for a subscription.
485516
*

0 commit comments

Comments
 (0)