Skip to content

Commit

Permalink
Merge pull request #36 from nevermined-io/feat/support-list-services-…
Browse files Browse the repository at this point in the history
…and-files

feat: support listing of services and datasets associated to a subsci…
  • Loading branch information
eruizgar91 authored Apr 4, 2024
2 parents ef7449e + da09b20 commit 3fb7515
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
36 changes: 36 additions & 0 deletions src/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 3fb7515

Please sign in to comment.