@@ -464,6 +464,55 @@ export class Payments {
464
464
return response . json ( )
465
465
}
466
466
467
+ /**
468
+ * Get the DDO for a given DID.
469
+ *
470
+ * @param did - The DID of the asset.
471
+ * @returns A promise that resolves to the DDO.
472
+ */
473
+ public async getAssetDDO ( did : string ) {
474
+ const url = new URL ( `/api/v1/payments/asset/ddo/${ did } ` , this . environment . backend )
475
+ const response = await fetch ( url )
476
+ if ( ! response . ok ) {
477
+ throw Error ( response . statusText )
478
+ }
479
+
480
+ return response . json ( )
481
+ }
482
+
483
+ /**
484
+ * Get the balance of an account for a subscription.
485
+ *
486
+ * @param subscriptionDid - The subscription DID of the service to be published.
487
+ * @param accountAddress - The address of the account to get the balance.
488
+ * @returns A promise that resolves to the balance result.
489
+ */
490
+ public async getSubscriptionBalance (
491
+ subscriptionDid : string ,
492
+ accountAddress ?: string ,
493
+ ) : Promise < { subscriptionType : string ; isOwner : boolean ; balance : bigint } > {
494
+ const body = {
495
+ subscriptionDid,
496
+ accountAddress,
497
+ sessionKey : this . sessionKey ,
498
+ }
499
+ const options = {
500
+ method : 'POST' ,
501
+ headers : {
502
+ Accept : 'application/json' ,
503
+ 'Content-Type' : 'application/json' ,
504
+ } ,
505
+ body : JSON . stringify ( body ) ,
506
+ }
507
+ const url = new URL ( '/api/v1/payments/subscription/balance' , this . environment . backend )
508
+ const response = await fetch ( url , options )
509
+ if ( ! response . ok ) {
510
+ throw Error ( response . statusText )
511
+ }
512
+
513
+ return response . json ( )
514
+ }
515
+
467
516
/**
468
517
* Get the service token for a given DID.
469
518
*
0 commit comments