diff --git a/package.json b/package.json index 51a4a22..6bed7a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/payments", - "version": "0.1.8", + "version": "0.1.9", "description": "Typescript SDK to interact with the Nevermined Payments Protocol", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/payments.ts b/src/payments.ts index 50f4198..d83b045 100644 --- a/src/payments.ts +++ b/src/payments.ts @@ -480,6 +480,42 @@ export class Payments { return response.json() } + /** + * Get array of services DIDs associated with a subscription. + * + * @param did - The DID of the asset. + * @returns A promise that resolves to the array of services DIDs. + */ + public async getSubscriptionAssociatedServices(subscriptionDid: string) { + const url = new URL( + `/api/v1/payments/subscription/services/${subscriptionDid}`, + this.environment.backend, + ) + const response = await fetch(url) + if (!response.ok) { + throw Error(response.statusText) + } + return response.json() + } + + /** + * Get array of files DIDs associated with a subscription. + * + * @param did - The DID of the asset. + * @returns A promise that resolves to array of files DIDs. + */ + public async getSubscriptionAssociatedFiles(subscriptionDid: string) { + const url = new URL( + `/api/v1/payments/subscription/files/${subscriptionDid}`, + this.environment.backend, + ) + const response = await fetch(url) + if (!response.ok) { + throw Error(response.statusText) + } + return response.json() + } + /** * Get the balance of an account for a subscription. *