class BluumClient {
constructor(apiKey, apiSecret, baseUrl = 'https://test-service.bluumfinance.com/v1') {
this.baseUrl = baseUrl;
this.auth = 'Basic ' + Buffer.from(`${apiKey}:${apiSecret}`).toString('base64');
}
async request(method, path, body) {
const response = await fetch(`${this.baseUrl}${path}`, {
method,
headers: {
'Authorization': this.auth,
'Content-Type': 'application/json'
},
body: body ? JSON.stringify(body) : undefined
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
return response.json();
}
getAccounts() { return this.request('GET', '/accounts'); }
createAccount(data) { return this.request('POST', '/accounts', data); }
getAssets(params) { return this.request('GET', `/assets/list?${new URLSearchParams(params)}`); }
placeOrder(accountId, order) { return this.request('POST', `/trading/accounts/${accountId}/orders`, order); }
}