Map<String, Object> nsCustomer = new Map<String, Object>();
nsCustomer.put('internalId', '123');
// Initialize the Customer Addresses
List<Object> addressBookList = new List<Object>();
// Adding new Address
Map<String, Object> addressBook = new Map<String, Object>();
Map<String, Object> addressbookAddress = new Map<String, Object>();
addressbookAddress.put('addr1','2334 N. Michigan Avenue, Suite 1500');
addressbookAddress.put('city','Chicago');
addressbookAddress.put('state','IL');
addressbookAddress.put('country','_unitedStates');
addressbookAddress.put('zip','60601');
addressBook.put('addressbookAddress',addressbookAddress);
addressBook.put('defaultBilling',true);
addressBook.put('isResidential',true);
addressBook.put('Label','Michigan Avenue');
addressBookList.add(addressBook);
// Updating the existing Address
Map<String, Object> addressBook1 = new Map<String, Object>();
addressBook1.put('internalId','3512');
Map<String, Object> addressbookAddress1 = new Map<String, Object>();
addressbookAddress1.put('addr1','525 S. Lexington Ave');
addressbookAddress1.put('city','Burlington');
addressbookAddress.put('state','NC');
addressbookAddress.put('country','_unitedStates');
addressbookAddress.put('zip','27215');
addressBook1.put('addressbookAddress',addressbookAddress);
addressBook.put('defaultShipping',true);
addressBook1.put('Label','Lexington Ave');
addressBookList.add(addressBook1);
// Adding the Addresses to Customer
Map<String, Object> customerAddressBookList = new Map<String, Object>();
customerAddressBookList .put('addressbook',addressBookList);
customerAddressBookList .put('replaceAll', false);
nsCustomer.put('addressBookList',customerAddressBookList );
// Initialize the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('customers', new List<Object>{nsCustomer});
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'updateCustomer');
reqObj.put('requestJSON', reqJSON);
// Place a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);