Skip to content

Commit f2a4458

Browse files
authored
Merge pull request #195 from companieshouse/map-transaction-to-resource-before-posting
Map transaction to resource prior to posting
2 parents 50f4904 + 2f6e576 commit f2a4458

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/services/transaction/service.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export default class TransactionService {
1616
url += "/" + transaction.id
1717
}
1818

19-
const resp = await this.client.httpPost(url, transaction);
19+
const transactionResource: TransactionResource = this.mapToResource(transaction);
20+
21+
const resp = await this.client.httpPost(url, transactionResource);
2022

2123
if (resp.error) {
2224
return {
@@ -48,4 +50,21 @@ export default class TransactionService {
4850
}
4951
return resource;
5052
}
53+
54+
private mapToResource (transaction:Transaction):TransactionResource {
55+
return {
56+
company_name: transaction.companyName,
57+
company_number: transaction.companyNumber,
58+
created_at: transaction.createdAt,
59+
created_by: transaction.createdBy,
60+
description: transaction.description,
61+
etag: transaction.etag,
62+
id: transaction.id,
63+
kind: transaction.kind,
64+
links: transaction.links,
65+
reference: transaction.reference,
66+
status: transaction.status,
67+
updated_at: transaction.updatedAt
68+
}
69+
}
5170
}

0 commit comments

Comments
 (0)