// Create a Map to store all the data of a Bill
List<Object> billList = new List<Object>();
Map<String, Object> billMap = new Map<String, Object>();
billMap.put('Type', 'ACCPAY');
billMap.put('DateString', '2021-11-11T00:00:00');
billMap.put('DueDateString', '2021-12-06T00:00:00');
billMap.put('Status', 'DRAFT');
billMap.put('InvoiceNumber', 'This is the reference for Bill');
// Initializing the Bill
Map<String, Object> contactMap = new Map<String, Object>();
contactMap.put('ContactID', 'c84ebb15-0a8d-4145-933f-203e68d014a0');
billMap.put('Contact', contactMap);
// Initializing the Bill Line Items
List<Object> lineItemList = new List<Object>();
Map<String, Object> lineItemMap = new Map<String, Object>();
lineItemMap.put('Description', 'Line Item Description');
lineItemMap.put('UnitAmount', 100);
lineItemMap.put('Quantity', 10);
lineItemMap.put('AccountCode', '310');
lineItemList.add(lineItemMap);
// Adding the Line Items to Bill
billMap.put('LineItems', lineItemList);
billList.add(billMap);
// Initializing the RequestJSON Data to be passed.
Map<String, Object> reqJSONMap = new Map<String, Object>();
reqJSONMap.put('invoices', billList);
String reqJSON = JSON.serialize(reqJSONMap);
Map<String, Object> finalReqMap = new Map<String, Object>();
finalReqMap.put('version', '1.0');
finalReqMap.put('action', 'createBill');
finalReqMap.put('RequestJSON', reqJSON);
finalReqMap.put('skipDML', false);
//Required, if Xero Multi-Org is enabled in Breadwinner.
finalReqMap.put('xeroOrgId', '!aa00TM');
System.debug('Request ::: ' + finalReqMap);
// Placing a request to Breadwinner Global API
Map<String, Object> respMap = bread_winner.BreadwinnerXeroAPI.call(finalReqMap);
System.debug('Response ::: ' + respMap);