fix(tests): fix test failures and draft payment API compatibility

This commit is contained in:
2025-07-22 20:40:32 +00:00
parent 036d111fa1
commit 36bab3eccb
4 changed files with 58 additions and 22 deletions

View File

@@ -35,9 +35,19 @@ export class BunqDraftPayment {
}): Promise<number> {
await this.bunqAccount.apiContext.ensureValidSession();
// Convert to snake_case for API
const apiPayload: any = {
entries: options.entries,
};
if (options.description) apiPayload.description = options.description;
if (options.status) apiPayload.status = options.status;
if (options.previousAttachmentId) apiPayload.previous_attachment_id = options.previousAttachmentId;
if (options.numberOfRequiredAccepts !== undefined) apiPayload.number_of_required_accepts = options.numberOfRequiredAccepts;
const response = await this.bunqAccount.getHttpClient().post(
`/v1/user/${this.bunqAccount.userId}/monetary-account/${this.monetaryAccount.id}/draft-payment`,
options
apiPayload
);
if (response.Response && response.Response[0] && response.Response[0].Id) {
@@ -86,9 +96,16 @@ export class BunqDraftPayment {
await this.bunqAccount.apiContext.ensureValidSession();
// Convert to snake_case for API
const apiPayload: any = {};
if (updates.description !== undefined) apiPayload.description = updates.description;
if (updates.status !== undefined) apiPayload.status = updates.status;
if (updates.entries !== undefined) apiPayload.entries = updates.entries;
if (updates.previousAttachmentId !== undefined) apiPayload.previous_attachment_id = updates.previousAttachmentId;
await this.bunqAccount.getHttpClient().put(
`/v1/user/${this.bunqAccount.userId}/monetary-account/${this.monetaryAccount.id}/draft-payment/${this.id}`,
updates
apiPayload // Send object directly, not wrapped in array
);
await this.get();