//Create a Map to store all the data of a Cash Sale
Map<String, Object> nsCashSale = new Map<String, Object>();
nsCashSale.put('internalId', '91704');
nsCashSale.put('classification', new Map<String, Object>{'internalId'=>'2'});
nsCashSale.put('department', new Map<String, Object>{'internalId'=>'1'});
nsCashSale.put('memo', 'CashSale 215');
nsCashSale.put('otherRefNum', '43434544');
// Initializing the Cash Sale Custom Fields
List<Object> csCustomFieldList = new List<Object>();
Map<String,Object> csCustomField = new Map<String,Object>();
csCustomField.put('fieldType', 'boolean');
csCustomField.put('scriptId', 'custbody_checkbox');
csCustomField.put('value', 'false');
csCustomFieldList.add(csCustomField);
// Adding the Cash Sale Custom Fields
nsCashSale.put('customFieldList', new Map<String,Object>{'customField'=>csCustomFieldList});
// Initializing the Cash Sale Line Items
List<Object> lineItemList = new List<Object>();
Map<String, Object> lineItem = new Map<String, Object>();
lineItem.put('description', ' For shooting arrows');
lineItem.put('line', 1); // updates the existing line item with line number as 1.
lineItem.put('quantity', 15);
// 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 Cash Sale Line Item Custom Fields
lineItem.put('customFieldList', new Map<String, Object>{'customField'=>liCustomFieldList});
lineItemList.add(lineItem);
// Adding the Line Items to Cash Sale
Map<String, Object> csLineitemList = new Map<String, Object>();
csLineitemList.put('item', lineItemList);
csLineitemList.put('replaceAll', false);
nsCashSale.put('itemList', csLineitemList);
// Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('cashSales', new List<Object>{nsCashSale});
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'updateCashSale');
reqObj.put('requestJSON', reqJSON);
// Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);