//Create a Map to store all the data of a Invoice
Map<String, Object> nsInvoice = new Map<String, Object>();
nsInvoice.put('classification', new Map<String, Object>{'internalId'=>'5'});
nsInvoice.put('currencyRecord', new Map<String, Object>{'internalId'=>'2'});
nsInvoice.put('department', new Map<String, Object>{'internalId'=>'2'});
nsInvoice.put('entity', new Map<String, Object>{'internalId'=>'362'});
nsInvoice.put('location',new Map<String, Object>{'internalId'=>'1'});
nsInvoice.put('memo', 'Invoice 100');
nsInvoice.put('otherRefNum', '4343399');
nsInvoice.put('tranDate', DateTime.newInstance(2020, 09, 07).getTime()/1000);
// Initializing the Invoice Custom Fields
List<Object> invCustomFieldList = new List<Object>();
Map<String,Object> invCustomField = new Map<String,Object>();
invCustomField.put('fieldType', 'select');
invCustomField.put('scriptId', 'custbody_customlist');
invCustomField.put('valueLookup', new Map<String,Object>{'internalId'=>'2'});
invCustomFieldList.add(invCustomField);
// Adding the Invoice Custom Fields
nsInvoice.put('customFieldList', new Map<String,Object>{'customField'=>invCustomFieldList});
// Initializing the Invoice Line Items
List<Object> lineItemList = new List<Object>();
Map<String, Object> lineItem = new Map<String, Object>();
lineItem.put('description', 'A weapon for shooting arrows');
lineItem.put('item', new Map<String, Object>{'internalId'=>'239'});
lineItem.put('quantity', 3);
// Initializing the Line Item custom fields
List<Object> liCustomFieldList = new List<Object>();
Map<String, Object> liCustomField = new Map<String, Object>();
liCustomField.put('fieldType', 'boolean');
liCustomField.put('scriptId', 'custcol_checkbox');
liCustomField.put('value', 'true');
liCustomFieldList.add(liCustomField);
// Adding the Invoice Line Item Custom Fields
lineItem.put('customFieldList', new Map<String, Object>{'customField'=>liCustomFieldList});
lineItemList.add(lineItem);
// Adding the Line Items to Invoice
Map<String, Object> invLineitemList = new Map<String, Object>();
invLineitemList.put('item', lineItemList);
nsInvoice.put('itemList', invLineitemList);
// Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('invoices', new List<Object>{nsInvoice});
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'createInvoice');
reqObj.put('requestJSON', reqJSON);
// Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);