1// Create a Map to store all the data of a Bill
2List<Object> billList = new List<Object>();
3Map<String, Object> billMap = new Map<String, Object>();
4 billMap.put('Type', 'ACCPAY');
5 billMap.put('DateString', '2021-11-11T00:00:00');
6 billMap.put('DueDateString', '2021-12-06T00:00:00');
7 billMap.put('Status', 'DRAFT');
8 billMap.put('InvoiceNumber', 'This is the reference for Bill');
9
10 // Initializing the Bill
11 Map<String, Object> contactMap = new Map<String, Object>();
12 contactMap.put('ContactID', 'c84ebb15-0a8d-4145-933f-203e68d014a0');
13 billMap.put('Contact', contactMap);
14 // Initializing the Bill Line Items
15 List<Object> lineItemList = new List<Object>();
16 Map<String, Object> lineItemMap = new Map<String, Object>();
17 lineItemMap.put('Description', 'Line Item Description');
18 lineItemMap.put('UnitAmount', 100);
19 lineItemMap.put('Quantity', 10);
20 lineItemMap.put('AccountCode', '310');
21 lineItemList.add(lineItemMap);
22
23 // Adding the Line Items to Bill
24 billMap.put('LineItems', lineItemList);
25 billList.add(billMap);
26
27// Initializing the RequestJSON Data to be passed.
28 Map<String, Object> reqJSONMap = new Map<String, Object>();
29 reqJSONMap.put('invoices', billList);
30 String reqJSON = JSON.serialize(reqJSONMap);
31
32 Map<String, Object> finalReqMap = new Map<String, Object>();
33 finalReqMap.put('version', '1.0');
34 finalReqMap.put('action', 'createBill');
35 finalReqMap.put('RequestJSON', reqJSON);
36 finalReqMap.put('skipDML', false);
37 //Required, if Xero Multi-Org is enabled in Breadwinner.
38 finalReqMap.put('xeroOrgId', '!aa00TM');
39 System.debug('Request ::: ' + finalReqMap);
40
41// Placing a request to Breadwinner Global API
42 Map<String, Object> respMap = bread_winner.BreadwinnerXeroAPI.call(finalReqMap);
43 System.debug('Response ::: ' + respMap);