@bloque/sdk-accounts 0.0.16 → 0.0.18
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 +392 -10
- package/dist/api-types.d.ts +15 -1
- package/dist/bancolombia/client.d.ts +85 -1
- package/dist/bancolombia/types.d.ts +25 -4
- package/dist/card/client.d.ts +85 -1
- package/dist/card/types.d.ts +27 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,22 +41,25 @@ const bloque = new SDK({
|
|
|
41
41
|
const card = await bloque.accounts.card.create({
|
|
42
42
|
urn: 'did:bloque:user:123',
|
|
43
43
|
name: 'My Virtual Card', // Optional
|
|
44
|
+
ledgerId: 'ledger_123', // Optional - associate with ledger account
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
console.log('Card created:', card.urn);
|
|
47
48
|
console.log('Last four digits:', card.lastFour);
|
|
48
49
|
console.log('Card details URL:', card.detailsUrl);
|
|
50
|
+
console.log('Ledger ID:', card.ledgerId);
|
|
49
51
|
console.log('Status:', card.status);
|
|
50
52
|
|
|
51
53
|
// Create a Bancolombia account
|
|
52
54
|
const bancolombiaAccount = await bloque.accounts.bancolombia.create({
|
|
53
55
|
urn: 'did:bloque:user:123',
|
|
54
56
|
name: 'Main Account', // Optional
|
|
55
|
-
|
|
57
|
+
ledgerId: 'ledger_123', // Optional - associate with ledger account
|
|
56
58
|
});
|
|
57
59
|
|
|
58
60
|
console.log('Bancolombia account created:', bancolombiaAccount.urn);
|
|
59
61
|
console.log('Reference code:', bancolombiaAccount.referenceCode);
|
|
62
|
+
console.log('Ledger ID:', bancolombiaAccount.ledgerId);
|
|
60
63
|
console.log('Status:', bancolombiaAccount.status);
|
|
61
64
|
```
|
|
62
65
|
|
|
@@ -72,6 +75,7 @@ Create virtual cards instantly.
|
|
|
72
75
|
const card = await bloque.accounts.card.create({
|
|
73
76
|
urn: 'did:bloque:user:123',
|
|
74
77
|
name: 'My Virtual Card', // Optional
|
|
78
|
+
ledgerId: 'ledger_123', // Optional
|
|
75
79
|
});
|
|
76
80
|
```
|
|
77
81
|
|
|
@@ -89,6 +93,21 @@ interface CreateCardParams {
|
|
|
89
93
|
* Display name for the card (optional)
|
|
90
94
|
*/
|
|
91
95
|
name?: string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Ledger account ID to associate with the card (optional)
|
|
99
|
+
*/
|
|
100
|
+
ledgerId?: string;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Webhook URL to receive card events (optional)
|
|
104
|
+
*/
|
|
105
|
+
webhookUrl?: string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Custom metadata to associate with the card (optional)
|
|
109
|
+
*/
|
|
110
|
+
metadata?: Record<string, unknown>;
|
|
92
111
|
}
|
|
93
112
|
```
|
|
94
113
|
|
|
@@ -104,6 +123,7 @@ interface CardAccount {
|
|
|
104
123
|
cardType: 'VIRTUAL' | 'PHYSICAL'; // Card type
|
|
105
124
|
detailsUrl: string; // PCI-compliant URL to view card details
|
|
106
125
|
ownerUrn: string; // Owner URN
|
|
126
|
+
ledgerId: string; // Ledger account ID
|
|
107
127
|
webhookUrl: string | null; // Webhook URL (if configured)
|
|
108
128
|
metadata?: Record<string, unknown>; // Custom metadata
|
|
109
129
|
createdAt: string; // Creation timestamp (ISO 8601)
|
|
@@ -111,6 +131,101 @@ interface CardAccount {
|
|
|
111
131
|
}
|
|
112
132
|
```
|
|
113
133
|
|
|
134
|
+
#### `card.updateMetadata(params)`
|
|
135
|
+
|
|
136
|
+
Update the metadata of an existing card account.
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
const card = await bloque.accounts.card.updateMetadata({
|
|
140
|
+
urn: 'did:bloque:mediums:card:account:123',
|
|
141
|
+
metadata: {
|
|
142
|
+
updated_by: 'admin',
|
|
143
|
+
update_reason: 'customer_request',
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Parameters**:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
interface UpdateCardMetadataParams {
|
|
152
|
+
/**
|
|
153
|
+
* URN of the card account to update
|
|
154
|
+
* @example "did:bloque:mediums:card:account:123e4567"
|
|
155
|
+
*/
|
|
156
|
+
urn: string;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Metadata to update (name and source are reserved fields and cannot be modified)
|
|
160
|
+
*/
|
|
161
|
+
metadata: Record<string, unknown> & {
|
|
162
|
+
name?: never;
|
|
163
|
+
source?: never;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Returns**: `CardAccount`
|
|
169
|
+
|
|
170
|
+
#### `card.updateName(urn, name)`
|
|
171
|
+
|
|
172
|
+
Update the name of a card account.
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
const card = await bloque.accounts.card.updateName(
|
|
176
|
+
'did:bloque:mediums:card:account:123',
|
|
177
|
+
'My Business Card'
|
|
178
|
+
);
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Parameters**:
|
|
182
|
+
- `urn: string` - Card account URN
|
|
183
|
+
- `name: string` - New name for the card
|
|
184
|
+
|
|
185
|
+
**Returns**: `CardAccount`
|
|
186
|
+
|
|
187
|
+
#### `card.activate(urn)`
|
|
188
|
+
|
|
189
|
+
Activate a card account.
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
const card = await bloque.accounts.card.activate(
|
|
193
|
+
'did:bloque:mediums:card:account:123'
|
|
194
|
+
);
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Parameters**: `urn: string` - Card account URN
|
|
198
|
+
|
|
199
|
+
**Returns**: `CardAccount`
|
|
200
|
+
|
|
201
|
+
#### `card.freeze(urn)`
|
|
202
|
+
|
|
203
|
+
Freeze a card account.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
const card = await bloque.accounts.card.freeze(
|
|
207
|
+
'did:bloque:mediums:card:account:123'
|
|
208
|
+
);
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Parameters**: `urn: string` - Card account URN
|
|
212
|
+
|
|
213
|
+
**Returns**: `CardAccount`
|
|
214
|
+
|
|
215
|
+
#### `card.disable(urn)`
|
|
216
|
+
|
|
217
|
+
Disable a card account.
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
const card = await bloque.accounts.card.disable(
|
|
221
|
+
'did:bloque:mediums:card:account:123'
|
|
222
|
+
);
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Parameters**: `urn: string` - Card account URN
|
|
226
|
+
|
|
227
|
+
**Returns**: `CardAccount`
|
|
228
|
+
|
|
114
229
|
### Bancolombia Accounts
|
|
115
230
|
|
|
116
231
|
Create Bancolombia accounts with reference codes for local payments.
|
|
@@ -121,7 +236,7 @@ Create Bancolombia accounts with reference codes for local payments.
|
|
|
121
236
|
const account = await bloque.accounts.bancolombia.create({
|
|
122
237
|
urn: 'did:bloque:user:123',
|
|
123
238
|
name: 'Main Account', // Optional
|
|
124
|
-
|
|
239
|
+
ledgerId: 'ledger_123', // Optional
|
|
125
240
|
});
|
|
126
241
|
```
|
|
127
242
|
|
|
@@ -141,10 +256,14 @@ interface CreateBancolombiaAccountParams {
|
|
|
141
256
|
name?: string;
|
|
142
257
|
|
|
143
258
|
/**
|
|
144
|
-
*
|
|
145
|
-
* @example "did:bloque:card:123e4567"
|
|
259
|
+
* Ledger account ID to associate with the Bancolombia account (optional)
|
|
146
260
|
*/
|
|
147
|
-
|
|
261
|
+
ledgerId?: string;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Webhook URL to receive account events (optional)
|
|
265
|
+
*/
|
|
266
|
+
webhookUrl?: string;
|
|
148
267
|
|
|
149
268
|
/**
|
|
150
269
|
* Custom metadata to attach to the Bancolombia account (optional)
|
|
@@ -162,6 +281,7 @@ interface BancolombiaAccount {
|
|
|
162
281
|
referenceCode: string; // Reference code for payments
|
|
163
282
|
status: 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
|
|
164
283
|
ownerUrn: string; // Owner URN
|
|
284
|
+
ledgerId: string; // Ledger account ID
|
|
165
285
|
webhookUrl: string | null; // Webhook URL (if configured)
|
|
166
286
|
metadata?: Record<string, unknown>; // Custom metadata
|
|
167
287
|
createdAt: string; // Creation timestamp (ISO 8601)
|
|
@@ -169,6 +289,101 @@ interface BancolombiaAccount {
|
|
|
169
289
|
}
|
|
170
290
|
```
|
|
171
291
|
|
|
292
|
+
#### `bancolombia.updateMetadata(params)`
|
|
293
|
+
|
|
294
|
+
Update the metadata of an existing Bancolombia account.
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
const account = await bloque.accounts.bancolombia.updateMetadata({
|
|
298
|
+
urn: 'did:bloque:mediums:bancolombia:account:123',
|
|
299
|
+
metadata: {
|
|
300
|
+
updated_by: 'admin',
|
|
301
|
+
update_reason: 'customer_request',
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Parameters**:
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
interface UpdateBancolombiaMetadataParams {
|
|
310
|
+
/**
|
|
311
|
+
* URN of the Bancolombia account to update
|
|
312
|
+
* @example "did:bloque:mediums:bancolombia:account:123e4567"
|
|
313
|
+
*/
|
|
314
|
+
urn: string;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Metadata to update (name and source are reserved fields and cannot be modified)
|
|
318
|
+
*/
|
|
319
|
+
metadata: Record<string, unknown> & {
|
|
320
|
+
name?: never;
|
|
321
|
+
source?: never;
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**Returns**: `BancolombiaAccount`
|
|
327
|
+
|
|
328
|
+
#### `bancolombia.updateName(urn, name)`
|
|
329
|
+
|
|
330
|
+
Update the name of a Bancolombia account.
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
const account = await bloque.accounts.bancolombia.updateName(
|
|
334
|
+
'did:bloque:mediums:bancolombia:account:123',
|
|
335
|
+
'Main Business Account'
|
|
336
|
+
);
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Parameters**:
|
|
340
|
+
- `urn: string` - Bancolombia account URN
|
|
341
|
+
- `name: string` - New name for the account
|
|
342
|
+
|
|
343
|
+
**Returns**: `BancolombiaAccount`
|
|
344
|
+
|
|
345
|
+
#### `bancolombia.activate(urn)`
|
|
346
|
+
|
|
347
|
+
Activate a Bancolombia account.
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
const account = await bloque.accounts.bancolombia.activate(
|
|
351
|
+
'did:bloque:mediums:bancolombia:account:123'
|
|
352
|
+
);
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Parameters**: `urn: string` - Bancolombia account URN
|
|
356
|
+
|
|
357
|
+
**Returns**: `BancolombiaAccount`
|
|
358
|
+
|
|
359
|
+
#### `bancolombia.freeze(urn)`
|
|
360
|
+
|
|
361
|
+
Freeze a Bancolombia account.
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
const account = await bloque.accounts.bancolombia.freeze(
|
|
365
|
+
'did:bloque:mediums:bancolombia:account:123'
|
|
366
|
+
);
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
**Parameters**: `urn: string` - Bancolombia account URN
|
|
370
|
+
|
|
371
|
+
**Returns**: `BancolombiaAccount`
|
|
372
|
+
|
|
373
|
+
#### `bancolombia.disable(urn)`
|
|
374
|
+
|
|
375
|
+
Disable a Bancolombia account.
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
const account = await bloque.accounts.bancolombia.disable(
|
|
379
|
+
'did:bloque:mediums:bancolombia:account:123'
|
|
380
|
+
);
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**Parameters**: `urn: string` - Bancolombia account URN
|
|
384
|
+
|
|
385
|
+
**Returns**: `BancolombiaAccount`
|
|
386
|
+
|
|
172
387
|
## Complete Examples
|
|
173
388
|
|
|
174
389
|
### Basic Card Creation
|
|
@@ -238,6 +453,86 @@ console.log('Personal card:', personalCard.lastFour);
|
|
|
238
453
|
console.log('Business card:', businessCard.lastFour);
|
|
239
454
|
```
|
|
240
455
|
|
|
456
|
+
### Updating Card Metadata
|
|
457
|
+
|
|
458
|
+
```typescript
|
|
459
|
+
import { SDK } from '@bloque/sdk';
|
|
460
|
+
|
|
461
|
+
const bloque = new SDK({
|
|
462
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
463
|
+
mode: 'production',
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
// Create a card first
|
|
467
|
+
const card = await bloque.accounts.card.create({
|
|
468
|
+
urn: 'did:bloque:user:123e4567',
|
|
469
|
+
name: 'My Card',
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
// Update the card metadata
|
|
473
|
+
const updatedCard = await bloque.accounts.card.updateMetadata({
|
|
474
|
+
urn: card.urn,
|
|
475
|
+
metadata: {
|
|
476
|
+
updated_by: 'admin',
|
|
477
|
+
update_reason: 'customer_request',
|
|
478
|
+
custom_field: 'custom_value',
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
console.log('Card metadata updated:', updatedCard.metadata);
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### Updating Card Name
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
import { SDK } from '@bloque/sdk';
|
|
489
|
+
|
|
490
|
+
const bloque = new SDK({
|
|
491
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
492
|
+
mode: 'production',
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
// Update the card name
|
|
496
|
+
const updatedCard = await bloque.accounts.card.updateName(
|
|
497
|
+
'did:bloque:mediums:card:account:123',
|
|
498
|
+
'My Personal Card'
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
console.log('Card name updated:', updatedCard.metadata?.name); // 'My Personal Card'
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Updating Card Status
|
|
505
|
+
|
|
506
|
+
```typescript
|
|
507
|
+
import { SDK } from '@bloque/sdk';
|
|
508
|
+
|
|
509
|
+
const bloque = new SDK({
|
|
510
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
511
|
+
mode: 'production',
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
// Freeze a card
|
|
515
|
+
const frozenCard = await bloque.accounts.card.freeze(
|
|
516
|
+
'did:bloque:mediums:card:account:123'
|
|
517
|
+
);
|
|
518
|
+
|
|
519
|
+
console.log('Card status:', frozenCard.status); // 'frozen'
|
|
520
|
+
|
|
521
|
+
// Reactivate the card
|
|
522
|
+
const activeCard = await bloque.accounts.card.activate(
|
|
523
|
+
'did:bloque:mediums:card:account:123'
|
|
524
|
+
);
|
|
525
|
+
|
|
526
|
+
console.log('Card status:', activeCard.status); // 'active'
|
|
527
|
+
|
|
528
|
+
// Disable a card
|
|
529
|
+
const disabledCard = await bloque.accounts.card.disable(
|
|
530
|
+
'did:bloque:mediums:card:account:123'
|
|
531
|
+
);
|
|
532
|
+
|
|
533
|
+
console.log('Card status:', disabledCard.status); // 'disabled'
|
|
534
|
+
```
|
|
535
|
+
|
|
241
536
|
### Error Handling
|
|
242
537
|
|
|
243
538
|
```typescript
|
|
@@ -289,7 +584,7 @@ console.log('Reference code:', account.referenceCode);
|
|
|
289
584
|
console.log('Status:', account.status);
|
|
290
585
|
```
|
|
291
586
|
|
|
292
|
-
### Bancolombia Account with
|
|
587
|
+
### Bancolombia Account with Ledger Association
|
|
293
588
|
|
|
294
589
|
```typescript
|
|
295
590
|
import { SDK } from '@bloque/sdk';
|
|
@@ -300,22 +595,26 @@ const bloque = new SDK({
|
|
|
300
595
|
});
|
|
301
596
|
|
|
302
597
|
const userUrn = 'did:bloque:user:123e4567';
|
|
598
|
+
const ledgerId = 'ledger_abc123';
|
|
303
599
|
|
|
304
|
-
// Create a card
|
|
600
|
+
// Create a card associated with a ledger
|
|
305
601
|
const card = await bloque.accounts.card.create({
|
|
306
602
|
urn: userUrn,
|
|
307
603
|
name: 'My Card',
|
|
604
|
+
ledgerId: ledgerId,
|
|
308
605
|
});
|
|
309
606
|
|
|
310
|
-
// Create Bancolombia account
|
|
607
|
+
// Create Bancolombia account with the same ledger
|
|
311
608
|
const account = await bloque.accounts.bancolombia.create({
|
|
312
609
|
urn: userUrn,
|
|
313
610
|
name: 'Main Account',
|
|
314
|
-
|
|
611
|
+
ledgerId: ledgerId,
|
|
315
612
|
});
|
|
316
613
|
|
|
317
614
|
console.log('Card URN:', card.urn);
|
|
615
|
+
console.log('Card Ledger ID:', card.ledgerId);
|
|
318
616
|
console.log('Account URN:', account.urn);
|
|
617
|
+
console.log('Account Ledger ID:', account.ledgerId);
|
|
319
618
|
console.log('Reference code for payments:', account.referenceCode);
|
|
320
619
|
```
|
|
321
620
|
|
|
@@ -344,6 +643,86 @@ console.log('Account created with metadata:', account.metadata);
|
|
|
344
643
|
console.log('Reference code:', account.referenceCode);
|
|
345
644
|
```
|
|
346
645
|
|
|
646
|
+
### Updating Bancolombia Account Metadata
|
|
647
|
+
|
|
648
|
+
```typescript
|
|
649
|
+
import { SDK } from '@bloque/sdk';
|
|
650
|
+
|
|
651
|
+
const bloque = new SDK({
|
|
652
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
653
|
+
mode: 'production',
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
// Create a Bancolombia account first
|
|
657
|
+
const account = await bloque.accounts.bancolombia.create({
|
|
658
|
+
urn: 'did:bloque:user:123e4567',
|
|
659
|
+
name: 'Main Account',
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
// Update the account metadata
|
|
663
|
+
const updatedAccount = await bloque.accounts.bancolombia.updateMetadata({
|
|
664
|
+
urn: account.urn,
|
|
665
|
+
metadata: {
|
|
666
|
+
updated_by: 'admin',
|
|
667
|
+
update_reason: 'customer_request',
|
|
668
|
+
department: 'finance',
|
|
669
|
+
},
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
console.log('Account metadata updated:', updatedAccount.metadata);
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
### Updating Bancolombia Account Name
|
|
676
|
+
|
|
677
|
+
```typescript
|
|
678
|
+
import { SDK } from '@bloque/sdk';
|
|
679
|
+
|
|
680
|
+
const bloque = new SDK({
|
|
681
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
682
|
+
mode: 'production',
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
// Update the account name
|
|
686
|
+
const updatedAccount = await bloque.accounts.bancolombia.updateName(
|
|
687
|
+
'did:bloque:mediums:bancolombia:account:123',
|
|
688
|
+
'Main Business Account'
|
|
689
|
+
);
|
|
690
|
+
|
|
691
|
+
console.log('Account name updated:', updatedAccount.metadata?.name); // 'Main Business Account'
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
### Updating Bancolombia Account Status
|
|
695
|
+
|
|
696
|
+
```typescript
|
|
697
|
+
import { SDK } from '@bloque/sdk';
|
|
698
|
+
|
|
699
|
+
const bloque = new SDK({
|
|
700
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
701
|
+
mode: 'production',
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
// Freeze a Bancolombia account
|
|
705
|
+
const frozenAccount = await bloque.accounts.bancolombia.freeze(
|
|
706
|
+
'did:bloque:mediums:bancolombia:account:123'
|
|
707
|
+
);
|
|
708
|
+
|
|
709
|
+
console.log('Account status:', frozenAccount.status); // 'frozen'
|
|
710
|
+
|
|
711
|
+
// Reactivate the account
|
|
712
|
+
const activeAccount = await bloque.accounts.bancolombia.activate(
|
|
713
|
+
'did:bloque:mediums:bancolombia:account:123'
|
|
714
|
+
);
|
|
715
|
+
|
|
716
|
+
console.log('Account status:', activeAccount.status); // 'active'
|
|
717
|
+
|
|
718
|
+
// Disable an account
|
|
719
|
+
const disabledAccount = await bloque.accounts.bancolombia.disable(
|
|
720
|
+
'did:bloque:mediums:bancolombia:account:123'
|
|
721
|
+
);
|
|
722
|
+
|
|
723
|
+
console.log('Account status:', disabledAccount.status); // 'disabled'
|
|
724
|
+
```
|
|
725
|
+
|
|
347
726
|
## TypeScript Support
|
|
348
727
|
|
|
349
728
|
This package is written in TypeScript and includes complete type definitions:
|
|
@@ -352,8 +731,10 @@ This package is written in TypeScript and includes complete type definitions:
|
|
|
352
731
|
import type {
|
|
353
732
|
CardAccount,
|
|
354
733
|
CreateCardParams,
|
|
734
|
+
UpdateCardMetadataParams,
|
|
355
735
|
BancolombiaAccount,
|
|
356
736
|
CreateBancolombiaAccountParams,
|
|
737
|
+
UpdateBancolombiaMetadataParams,
|
|
357
738
|
} from '@bloque/sdk-accounts';
|
|
358
739
|
|
|
359
740
|
// Type-safe card creation
|
|
@@ -373,13 +754,14 @@ console.log(card.cardType); // 'VIRTUAL' | 'PHYSICAL'
|
|
|
373
754
|
const accountParams: CreateBancolombiaAccountParams = {
|
|
374
755
|
urn: 'did:bloque:user:123e4567',
|
|
375
756
|
name: 'Main Account', // Optional
|
|
376
|
-
|
|
757
|
+
ledgerId: 'ledger_123', // Optional
|
|
377
758
|
};
|
|
378
759
|
|
|
379
760
|
const account: BancolombiaAccount = await bloque.accounts.bancolombia.create(accountParams);
|
|
380
761
|
|
|
381
762
|
// TypeScript infers all account properties with full type safety
|
|
382
763
|
console.log(account.referenceCode); // string
|
|
764
|
+
console.log(account.ledgerId); // string
|
|
383
765
|
console.log(account.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
|
|
384
766
|
```
|
|
385
767
|
|
package/dist/api-types.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
export type AccountStatus = 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
|
|
1
2
|
interface Account<TDetails = unknown> {
|
|
2
3
|
id: string;
|
|
3
4
|
urn: string;
|
|
4
5
|
medium: 'bancolombia' | 'card';
|
|
5
6
|
details: TDetails;
|
|
6
|
-
|
|
7
|
+
ledger_account_id: string;
|
|
8
|
+
status: AccountStatus;
|
|
7
9
|
owner_urn: string;
|
|
8
10
|
created_at: string;
|
|
9
11
|
updated_at: string;
|
|
@@ -13,6 +15,7 @@ interface Account<TDetails = unknown> {
|
|
|
13
15
|
export type CardType = 'VIRTUAL' | 'PHYSICAL';
|
|
14
16
|
export interface CreateAccountRequest<TInput = unknown> {
|
|
15
17
|
holder_urn: string;
|
|
18
|
+
ledger_account_id?: string;
|
|
16
19
|
input: TInput;
|
|
17
20
|
metadata?: Record<string, unknown>;
|
|
18
21
|
webhook_url?: string;
|
|
@@ -48,4 +51,15 @@ export type BancolombiaDetails = {
|
|
|
48
51
|
payment_agreement_code: string;
|
|
49
52
|
network: string[];
|
|
50
53
|
};
|
|
54
|
+
export interface UpdateAccountRequest<TInput = unknown> {
|
|
55
|
+
input?: TInput;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
status?: AccountStatus;
|
|
58
|
+
}
|
|
59
|
+
export interface UpdateAccountResponse<TDetails = unknown> {
|
|
60
|
+
result: {
|
|
61
|
+
account: Account<TDetails>;
|
|
62
|
+
};
|
|
63
|
+
req_id: string;
|
|
64
|
+
}
|
|
51
65
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
|
-
import type { BancolombiaAccount, CreateBancolombiaAccountParams } from './types';
|
|
2
|
+
import type { BancolombiaAccount, CreateBancolombiaAccountParams, UpdateBancolombiaMetadataParams } from './types';
|
|
3
3
|
export declare class BancolombiaClient {
|
|
4
4
|
private readonly httpClient;
|
|
5
5
|
constructor(httpClient: HttpClient);
|
|
@@ -18,4 +18,88 @@ export declare class BancolombiaClient {
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
create(params: CreateBancolombiaAccountParams): Promise<BancolombiaAccount>;
|
|
21
|
+
/**
|
|
22
|
+
* Update Bancolombia account metadata
|
|
23
|
+
*
|
|
24
|
+
* @param params - Metadata update parameters
|
|
25
|
+
* @returns Promise resolving to the updated Bancolombia account
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const account = await bloque.accounts.bancolombia.updateMetadata({
|
|
30
|
+
* urn: 'did:bloque:mediums:bancolombia:account:123',
|
|
31
|
+
* metadata: {
|
|
32
|
+
* updated_by: 'admin',
|
|
33
|
+
* update_reason: 'customer_request'
|
|
34
|
+
* }
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
updateMetadata(params: UpdateBancolombiaMetadataParams): Promise<BancolombiaAccount>;
|
|
39
|
+
/**
|
|
40
|
+
* Update Bancolombia account name
|
|
41
|
+
*
|
|
42
|
+
* @param urn - Bancolombia account URN
|
|
43
|
+
* @param name - New name for the account
|
|
44
|
+
* @returns Promise resolving to the updated Bancolombia account
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const account = await bloque.accounts.bancolombia.updateName(
|
|
49
|
+
* 'did:bloque:mediums:bancolombia:account:123',
|
|
50
|
+
* 'Main Business Account'
|
|
51
|
+
* );
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
updateName(urn: string, name: string): Promise<BancolombiaAccount>;
|
|
55
|
+
/**
|
|
56
|
+
* Activate a Bancolombia account
|
|
57
|
+
*
|
|
58
|
+
* @param urn - Bancolombia account URN
|
|
59
|
+
* @returns Promise resolving to the updated Bancolombia account
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const account = await bloque.accounts.bancolombia.activate(
|
|
64
|
+
* 'did:bloque:mediums:bancolombia:account:123'
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
activate(urn: string): Promise<BancolombiaAccount>;
|
|
69
|
+
/**
|
|
70
|
+
* Freeze a Bancolombia account
|
|
71
|
+
*
|
|
72
|
+
* @param urn - Bancolombia account URN
|
|
73
|
+
* @returns Promise resolving to the updated Bancolombia account
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const account = await bloque.accounts.bancolombia.freeze(
|
|
78
|
+
* 'did:bloque:mediums:bancolombia:account:123'
|
|
79
|
+
* );
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
freeze(urn: string): Promise<BancolombiaAccount>;
|
|
83
|
+
/**
|
|
84
|
+
* Disable a Bancolombia account
|
|
85
|
+
*
|
|
86
|
+
* @param urn - Bancolombia account URN
|
|
87
|
+
* @returns Promise resolving to the updated Bancolombia account
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const account = await bloque.accounts.bancolombia.disable(
|
|
92
|
+
* 'did:bloque:mediums:bancolombia:account:123'
|
|
93
|
+
* );
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
disable(urn: string): Promise<BancolombiaAccount>;
|
|
97
|
+
/**
|
|
98
|
+
* Private method to update Bancolombia account status
|
|
99
|
+
*/
|
|
100
|
+
private _updateStatus;
|
|
101
|
+
/**
|
|
102
|
+
* Private method to map API response to BancolombiaAccount
|
|
103
|
+
*/
|
|
104
|
+
private _mapAccountResponse;
|
|
21
105
|
}
|
|
@@ -10,16 +10,33 @@ export interface CreateBancolombiaAccountParams {
|
|
|
10
10
|
*/
|
|
11
11
|
name?: string;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
* Ledger account ID to associate with the Bancolombia account
|
|
14
|
+
*/
|
|
15
|
+
ledgerId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Webhook URL to receive account events
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
webhookUrl?: string;
|
|
18
20
|
/**
|
|
19
21
|
* Custom metadata to attach to the Bancolombia account
|
|
20
22
|
*/
|
|
21
23
|
metadata?: Record<string, unknown>;
|
|
22
24
|
}
|
|
25
|
+
export interface UpdateBancolombiaMetadataParams {
|
|
26
|
+
/**
|
|
27
|
+
* URN of the Bancolombia account to update
|
|
28
|
+
*
|
|
29
|
+
* @example "did:bloque:mediums:bancolombia:account:123e4567"
|
|
30
|
+
*/
|
|
31
|
+
urn: string;
|
|
32
|
+
/**
|
|
33
|
+
* Metadata to update (name and source are reserved fields and cannot be modified)
|
|
34
|
+
*/
|
|
35
|
+
metadata: Record<string, unknown> & {
|
|
36
|
+
name?: never;
|
|
37
|
+
source?: never;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
23
40
|
/**
|
|
24
41
|
* Bancolombia account response
|
|
25
42
|
*/
|
|
@@ -44,6 +61,10 @@ export interface BancolombiaAccount {
|
|
|
44
61
|
* Owner URN
|
|
45
62
|
*/
|
|
46
63
|
ownerUrn: string;
|
|
64
|
+
/**
|
|
65
|
+
* Ledger account ID associated with the card
|
|
66
|
+
*/
|
|
67
|
+
ledgerId: string;
|
|
47
68
|
/**
|
|
48
69
|
* Webhook URL (if configured)
|
|
49
70
|
*/
|
package/dist/card/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
|
-
import type { CardAccount, CreateCardParams } from './types';
|
|
2
|
+
import type { CardAccount, CreateCardParams, UpdateCardMetadataParams } from './types';
|
|
3
3
|
export declare class CardClient {
|
|
4
4
|
private readonly httpClient;
|
|
5
5
|
constructor(httpClient: HttpClient);
|
|
@@ -18,4 +18,88 @@ export declare class CardClient {
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
create(params: CreateCardParams): Promise<CardAccount>;
|
|
21
|
+
/**
|
|
22
|
+
* Update card account metadata
|
|
23
|
+
*
|
|
24
|
+
* @param params - Metadata update parameters
|
|
25
|
+
* @returns Promise resolving to the updated card account
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const card = await bloque.accounts.card.updateMetadata({
|
|
30
|
+
* urn: 'did:bloque:mediums:card:account:123',
|
|
31
|
+
* metadata: {
|
|
32
|
+
* updated_by: 'admin',
|
|
33
|
+
* update_reason: 'customer_request'
|
|
34
|
+
* }
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
updateMetadata(params: UpdateCardMetadataParams): Promise<CardAccount>;
|
|
39
|
+
/**
|
|
40
|
+
* Update card account name
|
|
41
|
+
*
|
|
42
|
+
* @param urn - Card account URN
|
|
43
|
+
* @param name - New name for the card
|
|
44
|
+
* @returns Promise resolving to the updated card account
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const card = await bloque.accounts.card.updateName(
|
|
49
|
+
* 'did:bloque:mediums:card:account:123',
|
|
50
|
+
* 'My Business Card'
|
|
51
|
+
* );
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
updateName(urn: string, name: string): Promise<CardAccount>;
|
|
55
|
+
/**
|
|
56
|
+
* Activate a card account
|
|
57
|
+
*
|
|
58
|
+
* @param urn - Card account URN
|
|
59
|
+
* @returns Promise resolving to the updated card account
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const card = await bloque.accounts.card.activate(
|
|
64
|
+
* 'did:bloque:mediums:card:account:123'
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
activate(urn: string): Promise<CardAccount>;
|
|
69
|
+
/**
|
|
70
|
+
* Freeze a card account
|
|
71
|
+
*
|
|
72
|
+
* @param urn - Card account URN
|
|
73
|
+
* @returns Promise resolving to the updated card account
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const card = await bloque.accounts.card.freeze(
|
|
78
|
+
* 'did:bloque:mediums:card:account:123'
|
|
79
|
+
* );
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
freeze(urn: string): Promise<CardAccount>;
|
|
83
|
+
/**
|
|
84
|
+
* Disable a card account
|
|
85
|
+
*
|
|
86
|
+
* @param urn - Card account URN
|
|
87
|
+
* @returns Promise resolving to the updated card account
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const card = await bloque.accounts.card.disable(
|
|
92
|
+
* 'did:bloque:mediums:card:account:123'
|
|
93
|
+
* );
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
disable(urn: string): Promise<CardAccount>;
|
|
97
|
+
/**
|
|
98
|
+
* Private method to update card status
|
|
99
|
+
*/
|
|
100
|
+
private _updateStatus;
|
|
101
|
+
/**
|
|
102
|
+
* Private method to map API response to CardAccount
|
|
103
|
+
*/
|
|
104
|
+
private _mapAccountResponse;
|
|
21
105
|
}
|
package/dist/card/types.d.ts
CHANGED
|
@@ -10,11 +10,34 @@ export interface CreateCardParams {
|
|
|
10
10
|
* Display name for the card
|
|
11
11
|
*/
|
|
12
12
|
name?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Webhook URL to receive card events
|
|
15
|
+
*/
|
|
16
|
+
webhookUrl?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Ledger account ID to associate with the card
|
|
19
|
+
*/
|
|
20
|
+
ledgerId?: string;
|
|
13
21
|
/**
|
|
14
22
|
* Custom metadata to associate with the card
|
|
15
23
|
*/
|
|
16
24
|
metadata?: Record<string, unknown>;
|
|
17
25
|
}
|
|
26
|
+
export interface UpdateCardMetadataParams {
|
|
27
|
+
/**
|
|
28
|
+
* URN of the card account to update
|
|
29
|
+
*
|
|
30
|
+
* @example "did:bloque:mediums:card:account:123e4567"
|
|
31
|
+
*/
|
|
32
|
+
urn: string;
|
|
33
|
+
/**
|
|
34
|
+
* Metadata to update (name and source are reserved fields and cannot be modified)
|
|
35
|
+
*/
|
|
36
|
+
metadata: Record<string, unknown> & {
|
|
37
|
+
name?: never;
|
|
38
|
+
source?: never;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
18
41
|
export interface CardAccount {
|
|
19
42
|
/**
|
|
20
43
|
* Unique resource name for the card account
|
|
@@ -48,6 +71,10 @@ export interface CardAccount {
|
|
|
48
71
|
* Owner URN
|
|
49
72
|
*/
|
|
50
73
|
ownerUrn: string;
|
|
74
|
+
/**
|
|
75
|
+
* Ledger account ID associated with the card
|
|
76
|
+
*/
|
|
77
|
+
ledgerId: string;
|
|
51
78
|
/**
|
|
52
79
|
* Webhook URL (if configured)
|
|
53
80
|
*/
|
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=(e
|
|
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__,{AccountsClient:()=>AccountsClient,CardClient:()=>CardClient,BancolombiaClient:()=>BancolombiaClient});class BancolombiaClient{httpClient;constructor(t){this.httpClient=t}async create(t){let e={holder_urn:t.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{httpClient;constructor(t){this.httpClient=t}async create(t){let e={holder_urn:t.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 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 AccountsClient{httpClient;bancolombia;card;constructor(t){this.httpClient=t,this.bancolombia=new BancolombiaClient(this.httpClient),this.card=new CardClient(this.httpClient)}}for(var __rspack_i in exports.AccountsClient=__webpack_exports__.AccountsClient,exports.BancolombiaClient=__webpack_exports__.BancolombiaClient,exports.CardClient=__webpack_exports__.CardClient,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","CardClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class t{httpClient;constructor(t){this.httpClient=t}async create(t){let e={holder_urn:t.urn,input:{},metadata:{source:"sdk-typescript",name:t.name
|
|
1
|
+
class t{httpClient;constructor(t){this.httpClient=t}async create(t){let e={holder_urn:t.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 e{httpClient;constructor(t){this.httpClient=t}async create(t){let e={holder_urn:t.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 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 a{httpClient;bancolombia;card;constructor(a){this.httpClient=a,this.bancolombia=new t(this.httpClient),this.card=new e(this.httpClient)}}export{a as AccountsClient,t as BancolombiaClient,e as CardClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-accounts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
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.
|
|
39
|
+
"@bloque/sdk-core": "0.0.18"
|
|
40
40
|
}
|
|
41
41
|
}
|