update
This commit is contained in:
39
examples/sandbox.ts
Normal file
39
examples/sandbox.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { BunqAccount } from '@apiclient.xyz/bunq';
|
||||
|
||||
async function sandboxExample() {
|
||||
// Step 1: Create a sandbox user and get API key
|
||||
console.log('Creating sandbox user...');
|
||||
|
||||
const tempBunq = new BunqAccount({
|
||||
apiKey: '', // Empty for sandbox user creation
|
||||
deviceName: 'Sandbox Test',
|
||||
environment: 'SANDBOX'
|
||||
});
|
||||
|
||||
const sandboxApiKey = await tempBunq.createSandboxUser();
|
||||
console.log('Sandbox API key:', sandboxApiKey);
|
||||
|
||||
// Step 2: Initialize with the generated API key
|
||||
const bunq = new BunqAccount({
|
||||
apiKey: sandboxApiKey,
|
||||
deviceName: 'Sandbox Test',
|
||||
environment: 'SANDBOX'
|
||||
});
|
||||
|
||||
await bunq.init();
|
||||
console.log('Connected to sandbox!');
|
||||
|
||||
// Step 3: Use the API as normal
|
||||
const accounts = await bunq.getAccounts();
|
||||
console.log(`Found ${accounts.length} sandbox accounts`);
|
||||
|
||||
for (const account of accounts) {
|
||||
console.log(`- ${account.description}: ${account.balance.currency} ${account.balance.value}`);
|
||||
}
|
||||
|
||||
// Clean up
|
||||
await bunq.stop();
|
||||
}
|
||||
|
||||
// Run the sandbox example
|
||||
sandboxExample().catch(console.error);
|
Reference in New Issue
Block a user