@bloque/sdk-accounts 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import type { HttpClient } from '@bloque/sdk-core';
2
2
  import { BaseClient } from '@bloque/sdk-core';
3
3
  import { BancolombiaClient } from './bancolombia/bancolombia-client';
4
4
  import { CardClient } from './card/card-client';
5
+ import { PolygonClient } from './polygon/polygon-client';
5
6
  import type { TransferParams, TransferResult } from './types';
6
7
  import { VirtualClient } from './virtual/virtual-client';
7
8
  /**
@@ -17,6 +18,7 @@ import { VirtualClient } from './virtual/virtual-client';
17
18
  export declare class AccountsClient extends BaseClient {
18
19
  readonly bancolombia: BancolombiaClient;
19
20
  readonly card: CardClient;
21
+ readonly polygon: PolygonClient;
20
22
  readonly virtual: VirtualClient;
21
23
  constructor(httpClient: HttpClient);
22
24
  /**
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(t,e)=>{for(var a in e)__webpack_require__.o(e,a)&&!__webpack_require__.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),__webpack_require__.r=t=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{CardClient:()=>CardClient,VirtualClient:()=>VirtualClient,AccountsClient:()=>AccountsClient,BancolombiaClient:()=>BancolombiaClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,referenceCode:t.details.reference_code,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class CardClient extends sdk_core_namespaceObject.BaseClient{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:e});return this._mapAccountResponse(a.result.account)}async list(t){let e=new URLSearchParams({holder_urn:t?.holderUrn||this.httpClient.urn||"",medium:"card"});return(await this.httpClient.request({method:"GET",path:`/api/accounts?${e.toString()}`})).accounts.map(t=>({urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:t.balance}))}async movements(t){let e=new URLSearchParams,a=t.asset||"DUSD/6";if("DUSD/6"!==a&&"KSM/12"!==a)throw Error("Invalid asset type. Supported assets are USD and KSM.");e.set("asset",a),void 0!==t.limit&&e.set("limit",t.limit.toString()),t.before&&e.set("before",t.before),t.after&&e.set("after",t.after),t.reference&&e.set("reference",t.reference),t.direction&&e.set("direction",t.direction);let r=e.toString(),s=`/api/accounts/${t.urn}/movements${r?`?${r}`:""}`;return(await this.httpClient.request({method:"GET",path:s})).transactions}async balance(t){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t.urn}/balance`})).balance}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class VirtualClient extends sdk_core_namespaceObject.BaseClient{async create(t){let e={first_name:t.firstName,last_name:t.lastName},a={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:e,metadata:{source:"sdk-typescript",...t.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a});return this._mapAccountResponse(r.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,firstName:t.details.first_name,lastName:t.details.last_name,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class AccountsClient extends sdk_core_namespaceObject.BaseClient{bancolombia;card;virtual;constructor(t){super(t),this.bancolombia=new BancolombiaClient(this.httpClient),this.card=new CardClient(this.httpClient),this.virtual=new VirtualClient(this.httpClient)}async transfer(t){let e=t.asset||"DUSD/6";if("DUSD/6"!==e&&"KSM/12"!==e)throw Error("Invalid asset type. Supported assets are USD and KSM.");let a={destination_account_urn:t.destinationUrn,amount:t.amount,asset:e,metadata:t.metadata},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${t.sourceUrn}/transfer`,body:a});return{queueId:r.result.queue_id,status:r.result.status,message:r.result.message}}}for(var __rspack_i in exports.AccountsClient=__webpack_exports__.AccountsClient,exports.BancolombiaClient=__webpack_exports__.BancolombiaClient,exports.CardClient=__webpack_exports__.CardClient,exports.VirtualClient=__webpack_exports__.VirtualClient,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","CardClient","VirtualClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(t,e)=>{for(var a in e)__webpack_require__.o(e,a)&&!__webpack_require__.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),__webpack_require__.r=t=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{CardClient:()=>CardClient,VirtualClient:()=>VirtualClient,PolygonClient:()=>PolygonClient,AccountsClient:()=>AccountsClient,BancolombiaClient:()=>BancolombiaClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,referenceCode:t.details.reference_code,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class CardClient extends sdk_core_namespaceObject.BaseClient{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:e});return this._mapAccountResponse(a.result.account)}async list(t){let e=new URLSearchParams({holder_urn:t?.holderUrn||this.httpClient.urn||"",medium:"card"});return(await this.httpClient.request({method:"GET",path:`/api/accounts?${e.toString()}`})).accounts.map(t=>({urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:t.balance}))}async movements(t){let e=new URLSearchParams,a=t.asset||"DUSD/6";if("DUSD/6"!==a&&"KSM/12"!==a)throw Error("Invalid asset type. Supported assets are USD and KSM.");e.set("asset",a),void 0!==t.limit&&e.set("limit",t.limit.toString()),t.before&&e.set("before",t.before),t.after&&e.set("after",t.after),t.reference&&e.set("reference",t.reference),t.direction&&e.set("direction",t.direction);let r=e.toString(),s=`/api/accounts/${t.urn}/movements${r?`?${r}`:""}`;return(await this.httpClient.request({method:"GET",path:s})).transactions}async balance(t){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t.urn}/balance`})).balance}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class PolygonClient extends sdk_core_namespaceObject.BaseClient{async create(t={}){let e={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,address:t.details.address,network:t.details.network,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class VirtualClient extends sdk_core_namespaceObject.BaseClient{async create(t){let e={first_name:t.firstName,last_name:t.lastName},a={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:e,metadata:{source:"sdk-typescript",...t.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a});return this._mapAccountResponse(r.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,firstName:t.details.first_name,lastName:t.details.last_name,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class AccountsClient extends sdk_core_namespaceObject.BaseClient{bancolombia;card;polygon;virtual;constructor(t){super(t),this.bancolombia=new BancolombiaClient(this.httpClient),this.card=new CardClient(this.httpClient),this.polygon=new PolygonClient(this.httpClient),this.virtual=new VirtualClient(this.httpClient)}async transfer(t){let e=t.asset||"DUSD/6";if("DUSD/6"!==e&&"KSM/12"!==e)throw Error("Invalid asset type. Supported assets are USD and KSM.");let a={destination_account_urn:t.destinationUrn,amount:t.amount,asset:e,metadata:t.metadata},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${t.sourceUrn}/transfer`,body:a});return{queueId:r.result.queue_id,status:r.result.status,message:r.result.message}}}for(var __rspack_i in exports.AccountsClient=__webpack_exports__.AccountsClient,exports.BancolombiaClient=__webpack_exports__.BancolombiaClient,exports.CardClient=__webpack_exports__.CardClient,exports.PolygonClient=__webpack_exports__.PolygonClient,exports.VirtualClient=__webpack_exports__.VirtualClient,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","CardClient","PolygonClient","VirtualClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
package/dist/index.d.ts CHANGED
@@ -3,6 +3,8 @@ export * from './bancolombia/bancolombia-client';
3
3
  export * from './bancolombia/types';
4
4
  export * from './card/card-client';
5
5
  export * from './card/types';
6
+ export * from './polygon/polygon-client';
7
+ export * from './polygon/types';
6
8
  export * from './types';
7
9
  export * from './virtual/types';
8
10
  export * from './virtual/virtual-client';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{BaseClient as t}from"@bloque/sdk-core";class e extends t{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,referenceCode:t.details.reference_code,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class a extends t{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:e});return this._mapAccountResponse(a.result.account)}async list(t){let e=new URLSearchParams({holder_urn:t?.holderUrn||this.httpClient.urn||"",medium:"card"});return(await this.httpClient.request({method:"GET",path:`/api/accounts?${e.toString()}`})).accounts.map(t=>({urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:t.balance}))}async movements(t){let e=new URLSearchParams,a=t.asset||"DUSD/6";if("DUSD/6"!==a&&"KSM/12"!==a)throw Error("Invalid asset type. Supported assets are USD and KSM.");e.set("asset",a),void 0!==t.limit&&e.set("limit",t.limit.toString()),t.before&&e.set("before",t.before),t.after&&e.set("after",t.after),t.reference&&e.set("reference",t.reference),t.direction&&e.set("direction",t.direction);let r=e.toString(),s=`/api/accounts/${t.urn}/movements${r?`?${r}`:""}`;return(await this.httpClient.request({method:"GET",path:s})).transactions}async balance(t){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t.urn}/balance`})).balance}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class r extends t{async create(t){let e={first_name:t.firstName,last_name:t.lastName},a={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:e,metadata:{source:"sdk-typescript",...t.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a});return this._mapAccountResponse(r.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,firstName:t.details.first_name,lastName:t.details.last_name,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class s extends t{bancolombia;card;virtual;constructor(t){super(t),this.bancolombia=new e(this.httpClient),this.card=new a(this.httpClient),this.virtual=new r(this.httpClient)}async transfer(t){let e=t.asset||"DUSD/6";if("DUSD/6"!==e&&"KSM/12"!==e)throw Error("Invalid asset type. Supported assets are USD and KSM.");let a={destination_account_urn:t.destinationUrn,amount:t.amount,asset:e,metadata:t.metadata},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${t.sourceUrn}/transfer`,body:a});return{queueId:r.result.queue_id,status:r.result.status,message:r.result.message}}}export{s as AccountsClient,e as BancolombiaClient,a as CardClient,r as VirtualClient};
1
+ import{BaseClient as t}from"@bloque/sdk-core";class e extends t{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,referenceCode:t.details.reference_code,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class a extends t{async create(t={}){let e={holder_urn:t?.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:e});return this._mapAccountResponse(a.result.account)}async list(t){let e=new URLSearchParams({holder_urn:t?.holderUrn||this.httpClient.urn||"",medium:"card"});return(await this.httpClient.request({method:"GET",path:`/api/accounts?${e.toString()}`})).accounts.map(t=>({urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:t.balance}))}async movements(t){let e=new URLSearchParams,a=t.asset||"DUSD/6";if("DUSD/6"!==a&&"KSM/12"!==a)throw Error("Invalid asset type. Supported assets are USD and KSM.");e.set("asset",a),void 0!==t.limit&&e.set("limit",t.limit.toString()),t.before&&e.set("before",t.before),t.after&&e.set("after",t.after),t.reference&&e.set("reference",t.reference),t.direction&&e.set("direction",t.direction);let s=e.toString(),r=`/api/accounts/${t.urn}/movements${s?`?${s}`:""}`;return(await this.httpClient.request({method:"GET",path:r})).transactions}async balance(t){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t.urn}/balance`})).balance}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class s extends t{async create(t={}){let e={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,address:t.details.address,network:t.details.network,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class r extends t{async create(t){let e={first_name:t.firstName,last_name:t.lastName},a={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:e,metadata:{source:"sdk-typescript",...t.metadata}},s=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a});return this._mapAccountResponse(s.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,firstName:t.details.first_name,lastName:t.details.last_name,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class n extends t{bancolombia;card;polygon;virtual;constructor(t){super(t),this.bancolombia=new e(this.httpClient),this.card=new a(this.httpClient),this.polygon=new s(this.httpClient),this.virtual=new r(this.httpClient)}async transfer(t){let e=t.asset||"DUSD/6";if("DUSD/6"!==e&&"KSM/12"!==e)throw Error("Invalid asset type. Supported assets are USD and KSM.");let a={destination_account_urn:t.destinationUrn,amount:t.amount,asset:e,metadata:t.metadata},s=await this.httpClient.request({method:"POST",path:`/api/accounts/${t.sourceUrn}/transfer`,body:a});return{queueId:s.result.queue_id,status:s.result.status,message:s.result.message}}}export{n as AccountsClient,e as BancolombiaClient,a as CardClient,s as PolygonClient,r as VirtualClient};
@@ -16,7 +16,7 @@ export type AccountStatus = 'active' | 'disabled' | 'frozen' | 'deleted' | 'crea
16
16
  export interface Account<TDetails = unknown> {
17
17
  id: string;
18
18
  urn: string;
19
- medium: 'bancolombia' | 'card' | 'virtual';
19
+ medium: 'bancolombia' | 'card' | 'virtual' | 'polygon';
20
20
  details: TDetails;
21
21
  ledger_account_id: string;
22
22
  status: AccountStatus;
@@ -106,6 +106,20 @@ export type VirtualDetails = {
106
106
  first_name: string;
107
107
  last_name: string;
108
108
  };
109
+ /**
110
+ * @internal
111
+ * Polygon account input for creation
112
+ */
113
+ export type CreatePolygonAccountInput = Record<string, never>;
114
+ /**
115
+ * @internal
116
+ * Polygon account details from API
117
+ */
118
+ export type PolygonDetails = {
119
+ id: string;
120
+ address: string;
121
+ network: string;
122
+ };
109
123
  /**
110
124
  * @internal
111
125
  * Update account request body
@@ -0,0 +1,87 @@
1
+ import { BaseClient } from '@bloque/sdk-core';
2
+ import type { CreatePolygonAccountParams, PolygonAccount, UpdatePolygonMetadataParams } from './types';
3
+ export declare class PolygonClient extends BaseClient {
4
+ /**
5
+ * Create a new polygon account
6
+ *
7
+ * Polygon accounts are cryptocurrency wallets on the Polygon network.
8
+ * They're created automatically without requiring additional input.
9
+ *
10
+ * @param params - Polygon account creation parameters
11
+ * @returns Promise resolving to the created polygon account
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const account = await bloque.accounts.polygon.create();
16
+ * ```
17
+ */
18
+ create(params?: CreatePolygonAccountParams): Promise<PolygonAccount>;
19
+ /**
20
+ * Update polygon account metadata
21
+ *
22
+ * @param params - Metadata update parameters
23
+ * @returns Promise resolving to the updated polygon account
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const account = await bloque.accounts.polygon.updateMetadata({
28
+ * urn: 'did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731',
29
+ * metadata: {
30
+ * updated_by: 'admin',
31
+ * update_reason: 'testing_update'
32
+ * }
33
+ * });
34
+ * ```
35
+ */
36
+ updateMetadata(params: UpdatePolygonMetadataParams): Promise<PolygonAccount>;
37
+ /**
38
+ * Activate a polygon account
39
+ *
40
+ * @param urn - Polygon account URN
41
+ * @returns Promise resolving to the updated polygon account
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const account = await bloque.accounts.polygon.activate(
46
+ * 'did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731'
47
+ * );
48
+ * ```
49
+ */
50
+ activate(urn: string): Promise<PolygonAccount>;
51
+ /**
52
+ * Freeze a polygon account
53
+ *
54
+ * @param urn - Polygon account URN
55
+ * @returns Promise resolving to the updated polygon account
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const account = await bloque.accounts.polygon.freeze(
60
+ * 'did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731'
61
+ * );
62
+ * ```
63
+ */
64
+ freeze(urn: string): Promise<PolygonAccount>;
65
+ /**
66
+ * Disable a polygon account
67
+ *
68
+ * @param urn - Polygon account URN
69
+ * @returns Promise resolving to the updated polygon account
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const account = await bloque.accounts.polygon.disable(
74
+ * 'did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731'
75
+ * );
76
+ * ```
77
+ */
78
+ disable(urn: string): Promise<PolygonAccount>;
79
+ /**
80
+ * Private method to update polygon account status
81
+ */
82
+ private _updateStatus;
83
+ /**
84
+ * Private method to map API response to PolygonAccount
85
+ */
86
+ private _mapAccountResponse;
87
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Parameters for creating a polygon account
3
+ */
4
+ export interface CreatePolygonAccountParams {
5
+ /**
6
+ * URN of the account holder (user or organization)
7
+ *
8
+ * @example "did:bloque:user:123e4567"
9
+ */
10
+ holderUrn?: string;
11
+ /**
12
+ * Ledger account ID to associate with the polygon account
13
+ * If not provided, a new ledger account will be created automatically
14
+ */
15
+ ledgerId?: string;
16
+ /**
17
+ * Webhook URL to receive account events
18
+ */
19
+ webhookUrl?: string;
20
+ /**
21
+ * Custom metadata to attach to the polygon account
22
+ * Must be a Record<string, string> (all values must be strings)
23
+ */
24
+ metadata?: Record<string, string>;
25
+ }
26
+ /**
27
+ * Parameters for updating polygon account metadata
28
+ */
29
+ export interface UpdatePolygonMetadataParams {
30
+ /**
31
+ * URN of the polygon account to update
32
+ *
33
+ * @example "did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731"
34
+ */
35
+ urn: string;
36
+ /**
37
+ * Metadata to update
38
+ * Note: 'source' is a reserved field and cannot be modified
39
+ */
40
+ metadata: Record<string, string> & {
41
+ source?: never;
42
+ };
43
+ }
44
+ /**
45
+ * Polygon account response
46
+ */
47
+ export interface PolygonAccount {
48
+ /**
49
+ * Unique resource name for the polygon account
50
+ */
51
+ urn: string;
52
+ /**
53
+ * Account ID
54
+ */
55
+ id: string;
56
+ /**
57
+ * Polygon wallet address
58
+ */
59
+ address: string;
60
+ /**
61
+ * Network name (always "polygon")
62
+ */
63
+ network: string;
64
+ /**
65
+ * Account status
66
+ */
67
+ status: 'creation_in_progress' | 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_failed';
68
+ /**
69
+ * Owner URN
70
+ */
71
+ ownerUrn: string;
72
+ /**
73
+ * Ledger account ID associated with the polygon account
74
+ */
75
+ ledgerId: string;
76
+ /**
77
+ * Webhook URL (if configured)
78
+ */
79
+ webhookUrl: string | null;
80
+ /**
81
+ * Custom metadata
82
+ */
83
+ metadata?: Record<string, string>;
84
+ /**
85
+ * Creation timestamp
86
+ */
87
+ createdAt: string;
88
+ /**
89
+ * Last update timestamp
90
+ */
91
+ updatedAt: string;
92
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk-accounts",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "bloque",
@@ -36,6 +36,6 @@
36
36
  "node": ">=22"
37
37
  },
38
38
  "dependencies": {
39
- "@bloque/sdk-core": "0.0.24"
39
+ "@bloque/sdk-core": "0.0.25"
40
40
  }
41
41
  }