@bloque/sdk-accounts 0.0.6 → 0.0.10

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.
package/README.md CHANGED
@@ -5,6 +5,7 @@ Financial accounts and payment methods client for the [Bloque](https://www.bloqu
5
5
  ## Features
6
6
 
7
7
  - **Virtual Cards**: Create virtual cards instantly
8
+ - **Bancolombia Accounts**: Create Bancolombia accounts with reference codes
8
9
  - **TypeScript First**: Built with TypeScript for complete type safety
9
10
  - **Simple API**: Minimal input required - just URN and optional name
10
11
  - **Fully Async**: Promise-based API for modern JavaScript workflows
@@ -46,6 +47,17 @@ console.log('Card created:', card.urn);
46
47
  console.log('Last four digits:', card.lastFour);
47
48
  console.log('Card details URL:', card.detailsUrl);
48
49
  console.log('Status:', card.status);
50
+
51
+ // Create a Bancolombia account
52
+ const bancolombiaAccount = await bloque.accounts.bancolombia.create({
53
+ urn: 'did:bloque:user:123',
54
+ name: 'Main Account', // Optional
55
+ cardUrn: card.urn, // Optional - link with existing card
56
+ });
57
+
58
+ console.log('Bancolombia account created:', bancolombiaAccount.urn);
59
+ console.log('Reference code:', bancolombiaAccount.referenceCode);
60
+ console.log('Status:', bancolombiaAccount.status);
49
61
  ```
50
62
 
51
63
  ## API Reference
@@ -99,6 +111,64 @@ interface CardAccount {
99
111
  }
100
112
  ```
101
113
 
114
+ ### Bancolombia Accounts
115
+
116
+ Create Bancolombia accounts with reference codes for local payments.
117
+
118
+ #### `bancolombia.create(params)`
119
+
120
+ ```typescript
121
+ const account = await bloque.accounts.bancolombia.create({
122
+ urn: 'did:bloque:user:123',
123
+ name: 'Main Account', // Optional
124
+ cardUrn: 'did:bloque:card:456', // Optional - link with existing card
125
+ });
126
+ ```
127
+
128
+ **Parameters**:
129
+
130
+ ```typescript
131
+ interface CreateBancolombiaAccountParams {
132
+ /**
133
+ * URN of the account holder (user or organization)
134
+ * @example "did:bloque:user:123e4567"
135
+ */
136
+ urn: string;
137
+
138
+ /**
139
+ * Display name for the account (optional)
140
+ */
141
+ name?: string;
142
+
143
+ /**
144
+ * URN of an existing card to link with the Bancolombia account (optional)
145
+ * @example "did:bloque:card:123e4567"
146
+ */
147
+ cardUrn?: string;
148
+
149
+ /**
150
+ * Custom metadata to attach to the Bancolombia account (optional)
151
+ */
152
+ metadata?: Record<string, unknown>;
153
+ }
154
+ ```
155
+
156
+ **Returns**:
157
+
158
+ ```typescript
159
+ interface BancolombiaAccount {
160
+ urn: string; // Unique resource name
161
+ id: string; // Account ID
162
+ referenceCode: string; // Reference code for payments
163
+ status: 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
164
+ ownerUrn: string; // Owner URN
165
+ webhookUrl: string | null; // Webhook URL (if configured)
166
+ metadata?: Record<string, unknown>; // Custom metadata
167
+ createdAt: string; // Creation timestamp (ISO 8601)
168
+ updatedAt: string; // Last update timestamp (ISO 8601)
169
+ }
170
+ ```
171
+
102
172
  ## Complete Examples
103
173
 
104
174
  ### Basic Card Creation
@@ -199,6 +269,81 @@ try {
199
269
  }
200
270
  ```
201
271
 
272
+ ### Basic Bancolombia Account Creation
273
+
274
+ ```typescript
275
+ import { SDK } from '@bloque/sdk';
276
+
277
+ const bloque = new SDK({
278
+ apiKey: process.env.BLOQUE_API_KEY!,
279
+ mode: 'production',
280
+ });
281
+
282
+ // Create a Bancolombia account with just URN
283
+ const account = await bloque.accounts.bancolombia.create({
284
+ urn: 'did:bloque:user:123e4567',
285
+ });
286
+
287
+ console.log('Account created:', account.urn);
288
+ console.log('Reference code:', account.referenceCode);
289
+ console.log('Status:', account.status);
290
+ ```
291
+
292
+ ### Bancolombia Account with Card Link
293
+
294
+ ```typescript
295
+ import { SDK } from '@bloque/sdk';
296
+
297
+ const bloque = new SDK({
298
+ apiKey: process.env.BLOQUE_API_KEY!,
299
+ mode: 'production',
300
+ });
301
+
302
+ const userUrn = 'did:bloque:user:123e4567';
303
+
304
+ // Create a card first
305
+ const card = await bloque.accounts.card.create({
306
+ urn: userUrn,
307
+ name: 'My Card',
308
+ });
309
+
310
+ // Create Bancolombia account and link it to the card
311
+ const account = await bloque.accounts.bancolombia.create({
312
+ urn: userUrn,
313
+ name: 'Main Account',
314
+ cardUrn: card.urn, // Link to existing card
315
+ });
316
+
317
+ console.log('Card URN:', card.urn);
318
+ console.log('Account URN:', account.urn);
319
+ console.log('Reference code for payments:', account.referenceCode);
320
+ ```
321
+
322
+ ### Bancolombia Account with Metadata
323
+
324
+ ```typescript
325
+ import { SDK } from '@bloque/sdk';
326
+
327
+ const bloque = new SDK({
328
+ apiKey: process.env.BLOQUE_API_KEY!,
329
+ mode: 'production',
330
+ });
331
+
332
+ // Create Bancolombia account with custom metadata
333
+ const account = await bloque.accounts.bancolombia.create({
334
+ urn: 'did:bloque:user:123e4567',
335
+ name: 'Business Account',
336
+ metadata: {
337
+ purpose: 'business-payments',
338
+ department: 'sales',
339
+ customField: 'custom-value',
340
+ },
341
+ });
342
+
343
+ console.log('Account created with metadata:', account.metadata);
344
+ console.log('Reference code:', account.referenceCode);
345
+ ```
346
+
202
347
  ## TypeScript Support
203
348
 
204
349
  This package is written in TypeScript and includes complete type definitions:
@@ -207,32 +352,47 @@ This package is written in TypeScript and includes complete type definitions:
207
352
  import type {
208
353
  CardAccount,
209
354
  CreateCardParams,
355
+ BancolombiaAccount,
356
+ CreateBancolombiaAccountParams,
210
357
  } from '@bloque/sdk-accounts';
211
358
 
212
359
  // Type-safe card creation
213
- const params: CreateCardParams = {
360
+ const cardParams: CreateCardParams = {
214
361
  urn: 'did:bloque:user:123e4567',
215
362
  name: 'My Card', // Optional
216
363
  };
217
364
 
218
- const card: CardAccount = await bloque.accounts.card.create(params);
365
+ const card: CardAccount = await bloque.accounts.card.create(cardParams);
219
366
 
220
367
  // TypeScript infers all card properties with full type safety
221
368
  console.log(card.lastFour); // string
222
369
  console.log(card.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
223
370
  console.log(card.cardType); // 'VIRTUAL' | 'PHYSICAL'
371
+
372
+ // Type-safe Bancolombia account creation
373
+ const accountParams: CreateBancolombiaAccountParams = {
374
+ urn: 'did:bloque:user:123e4567',
375
+ name: 'Main Account', // Optional
376
+ cardUrn: card.urn, // Optional
377
+ };
378
+
379
+ const account: BancolombiaAccount = await bloque.accounts.bancolombia.create(accountParams);
380
+
381
+ // TypeScript infers all account properties with full type safety
382
+ console.log(account.referenceCode); // string
383
+ console.log(account.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
224
384
  ```
225
385
 
226
- ## Card Status
386
+ ## Account Status
227
387
 
228
- Cards have a status field indicating their current state:
388
+ Both cards and Bancolombia accounts have a status field indicating their current state:
229
389
 
230
- - `creation_in_progress`: Card is being created
231
- - `creation_failed`: Card creation failed
232
- - `active`: Card is active and ready to use
233
- - `disabled`: Card has been disabled
234
- - `frozen`: Card has been temporarily frozen
235
- - `deleted`: Card has been deleted
390
+ - `creation_in_progress`: Account/card is being created
391
+ - `creation_failed`: Account/card creation failed
392
+ - `active`: Account/card is active and ready to use
393
+ - `disabled`: Account/card has been disabled
394
+ - `frozen`: Account/card has been temporarily frozen
395
+ - `deleted`: Account/card has been deleted
236
396
 
237
397
  ## Requirements
238
398
 
@@ -42,4 +42,10 @@ export type CardDetails = {
42
42
  card_type: CardType;
43
43
  user_id: string;
44
44
  };
45
+ export type BancolombiaDetails = {
46
+ id: string;
47
+ reference_code: string;
48
+ payment_agreement_code: string;
49
+ network: string[];
50
+ };
45
51
  export {};
@@ -0,0 +1,21 @@
1
+ import type { HttpClient } from '@bloque/sdk-core';
2
+ import type { BancolombiaAccount, CreateBancolombiaAccountParams } from './types';
3
+ export declare class BancolombiaClient {
4
+ private readonly httpClient;
5
+ constructor(httpClient: HttpClient);
6
+ /**
7
+ * Create a new Bancolombia account
8
+ *
9
+ * @param params - Bancolombia account creation parameters
10
+ * @returns Promise resolving to the created Bancolombia account
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const account = await bloque.accounts.bancolombia.create({
15
+ * urn: 'did:bloque:user:123',
16
+ * name: 'Main Account'
17
+ * });
18
+ * ```
19
+ */
20
+ create(params: CreateBancolombiaAccountParams): Promise<BancolombiaAccount>;
21
+ }
@@ -0,0 +1,63 @@
1
+ export interface CreateBancolombiaAccountParams {
2
+ /**
3
+ * URN of the account holder (user or organization)
4
+ *
5
+ * @example "did:bloque:user:123e4567"
6
+ */
7
+ urn: string;
8
+ /**
9
+ * Display name for the card
10
+ */
11
+ name?: string;
12
+ /**
13
+ * URN of an existing card to link with the Bancolombia account
14
+ *
15
+ * @example "did:bloque:card:123e4567"
16
+ */
17
+ cardUrn?: string;
18
+ /**
19
+ * Custom metadata to attach to the Bancolombia account
20
+ */
21
+ metadata?: Record<string, unknown>;
22
+ }
23
+ /**
24
+ * Bancolombia account response
25
+ */
26
+ export interface BancolombiaAccount {
27
+ /**
28
+ * Unique resource name for the Bancolombia account
29
+ */
30
+ urn: string;
31
+ /**
32
+ * Account ID
33
+ */
34
+ id: string;
35
+ /**
36
+ * Reference code for the Bancolombia account
37
+ */
38
+ referenceCode: string;
39
+ /**
40
+ * Account status
41
+ */
42
+ status: 'creation_in_progress' | 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_failed';
43
+ /**
44
+ * Owner URN
45
+ */
46
+ ownerUrn: string;
47
+ /**
48
+ * Webhook URL (if configured)
49
+ */
50
+ webhookUrl: string | null;
51
+ /**
52
+ * Custom metadata
53
+ */
54
+ metadata?: Record<string, unknown>;
55
+ /**
56
+ * Creation timestamp
57
+ */
58
+ createdAt: string;
59
+ /**
60
+ * Last update timestamp
61
+ */
62
+ updatedAt: string;
63
+ }
@@ -10,6 +10,10 @@ export interface CreateCardParams {
10
10
  * Display name for the card
11
11
  */
12
12
  name?: string;
13
+ /**
14
+ * Custom metadata to associate with the card
15
+ */
16
+ metadata?: Record<string, unknown>;
13
17
  }
14
18
  export interface CardAccount {
15
19
  /**
package/dist/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { HttpClient } from '@bloque/sdk-core';
2
+ import { BancolombiaClient } from './bancolombia/client';
2
3
  import { CardClient } from './card/client';
3
4
  /**
4
5
  * Accounts client for managing financial accounts and payment methods
@@ -12,6 +13,7 @@ import { CardClient } from './card/client';
12
13
  */
13
14
  export declare class AccountsClient {
14
15
  private readonly httpClient;
16
+ readonly bancolombia: BancolombiaClient;
15
17
  readonly card: CardClient;
16
18
  constructor(httpClient: HttpClient);
17
19
  }
package/dist/index.cjs CHANGED
@@ -25,8 +25,44 @@ var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  AccountsClient: ()=>AccountsClient,
28
- CardClient: ()=>CardClient
28
+ CardClient: ()=>CardClient,
29
+ BancolombiaClient: ()=>BancolombiaClient
29
30
  });
31
+ class BancolombiaClient {
32
+ httpClient;
33
+ constructor(httpClient){
34
+ this.httpClient = httpClient;
35
+ }
36
+ async create(params) {
37
+ const request = {
38
+ holder_urn: params.urn,
39
+ input: {},
40
+ metadata: {
41
+ source: "sdk-typescript",
42
+ name: params.name,
43
+ card_urn: params.cardUrn,
44
+ ...params.metadata
45
+ }
46
+ };
47
+ const response = await this.httpClient.request({
48
+ method: 'POST',
49
+ path: '/api/mediums/bancolombia',
50
+ body: request
51
+ });
52
+ const account = response.result.account;
53
+ return {
54
+ urn: account.urn,
55
+ id: account.id,
56
+ referenceCode: account.details.reference_code,
57
+ status: account.status,
58
+ ownerUrn: account.owner_urn,
59
+ webhookUrl: account.webhook_url,
60
+ metadata: account.metadata,
61
+ createdAt: account.created_at,
62
+ updatedAt: account.updated_at
63
+ };
64
+ }
65
+ }
30
66
  class CardClient {
31
67
  httpClient;
32
68
  constructor(httpClient){
@@ -42,7 +78,8 @@ class CardClient {
42
78
  },
43
79
  metadata: {
44
80
  source: "sdk-typescript",
45
- name: params.name
81
+ name: params.name,
82
+ ...params.metadata
46
83
  }
47
84
  };
48
85
  const response = await this.httpClient.request({
@@ -69,16 +106,20 @@ class CardClient {
69
106
  }
70
107
  class AccountsClient {
71
108
  httpClient;
109
+ bancolombia;
72
110
  card;
73
111
  constructor(httpClient){
74
112
  this.httpClient = httpClient;
113
+ this.bancolombia = new BancolombiaClient(this.httpClient);
75
114
  this.card = new CardClient(this.httpClient);
76
115
  }
77
116
  }
78
117
  exports.AccountsClient = __webpack_exports__.AccountsClient;
118
+ exports.BancolombiaClient = __webpack_exports__.BancolombiaClient;
79
119
  exports.CardClient = __webpack_exports__.CardClient;
80
120
  for(var __rspack_i in __webpack_exports__)if (-1 === [
81
121
  "AccountsClient",
122
+ "BancolombiaClient",
82
123
  "CardClient"
83
124
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
84
125
  Object.defineProperty(exports, '__esModule', {
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './bancolombia/client';
2
+ export * from './bancolombia/types';
1
3
  export * from './card/client';
2
4
  export * from './card/types';
3
5
  export * from './client';
package/dist/index.js CHANGED
@@ -1,3 +1,38 @@
1
+ class BancolombiaClient {
2
+ httpClient;
3
+ constructor(httpClient){
4
+ this.httpClient = httpClient;
5
+ }
6
+ async create(params) {
7
+ const request = {
8
+ holder_urn: params.urn,
9
+ input: {},
10
+ metadata: {
11
+ source: "sdk-typescript",
12
+ name: params.name,
13
+ card_urn: params.cardUrn,
14
+ ...params.metadata
15
+ }
16
+ };
17
+ const response = await this.httpClient.request({
18
+ method: 'POST',
19
+ path: '/api/mediums/bancolombia',
20
+ body: request
21
+ });
22
+ const account = response.result.account;
23
+ return {
24
+ urn: account.urn,
25
+ id: account.id,
26
+ referenceCode: account.details.reference_code,
27
+ status: account.status,
28
+ ownerUrn: account.owner_urn,
29
+ webhookUrl: account.webhook_url,
30
+ metadata: account.metadata,
31
+ createdAt: account.created_at,
32
+ updatedAt: account.updated_at
33
+ };
34
+ }
35
+ }
1
36
  class CardClient {
2
37
  httpClient;
3
38
  constructor(httpClient){
@@ -13,7 +48,8 @@ class CardClient {
13
48
  },
14
49
  metadata: {
15
50
  source: "sdk-typescript",
16
- name: params.name
51
+ name: params.name,
52
+ ...params.metadata
17
53
  }
18
54
  };
19
55
  const response = await this.httpClient.request({
@@ -40,10 +76,12 @@ class CardClient {
40
76
  }
41
77
  class AccountsClient {
42
78
  httpClient;
79
+ bancolombia;
43
80
  card;
44
81
  constructor(httpClient){
45
82
  this.httpClient = httpClient;
83
+ this.bancolombia = new BancolombiaClient(this.httpClient);
46
84
  this.card = new CardClient(this.httpClient);
47
85
  }
48
86
  }
49
- export { AccountsClient, CardClient };
87
+ export { AccountsClient, BancolombiaClient, CardClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk-accounts",
3
- "version": "0.0.6",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "bloque",
@@ -36,7 +36,7 @@
36
36
  "node": ">=22"
37
37
  },
38
38
  "scripts": {
39
- "publish": "bun publish",
39
+ "release": "bun publish",
40
40
  "build": "rslib build",
41
41
  "dev": "rslib build --watch",
42
42
  "clean": "rm -rf node_modules && rm -rf dist",