1Map<String, Object> nsCustomer = new Map<String, Object>();
2nsCustomer.put('internalId', '123');
3
4// Initialize the Customer Addresses
5List<Object> addressBookList = new List<Object>();
6
7// Adding new Address
8Map<String, Object> addressBook = new Map<String, Object>();
9Map<String, Object> addressbookAddress = new Map<String, Object>();
10addressbookAddress.put('addr1','2334 N. Michigan Avenue, Suite 1500');
11addressbookAddress.put('city','Chicago');
12addressbookAddress.put('state','IL');
13addressbookAddress.put('country','_unitedStates');
14addressbookAddress.put('zip','60601');
15
16addressBook.put('addressbookAddress',addressbookAddress);
17addressBook.put('defaultBilling',true);
18addressBook.put('isResidential',true);
19addressBook.put('Label','Michigan Avenue');
20
21addressBookList.add(addressBook);
22
23// Updating the existing Address
24Map<String, Object> addressBook1 = new Map<String, Object>();
25addressBook1.put('internalId','3512');
26Map<String, Object> addressbookAddress1 = new Map<String, Object>();
27addressbookAddress1.put('addr1','525 S. Lexington Ave');
28addressbookAddress1.put('city','Burlington');
29addressbookAddress.put('state','NC');
30addressbookAddress.put('country','_unitedStates');
31addressbookAddress.put('zip','27215');
32
33addressBook1.put('addressbookAddress',addressbookAddress);
34addressBook.put('defaultShipping',true);
35addressBook1.put('Label','Lexington Ave');
36
37addressBookList.add(addressBook1);
38
39// Adding the Addresses to Customer
40Map<String, Object> customerAddressBookList = new Map<String, Object>();
41customerAddressBookList .put('addressbook',addressBookList);
42customerAddressBookList .put('replaceAll', false);
43nsCustomer.put('addressBookList',customerAddressBookList );
44
45// Initialize the RequestJSON Data to be passed.
46Map<String, Object> requestJSONMap = new Map<String, Object>();
47requestJSONMap.put('customers', new List<Object>{nsCustomer});
48String reqJSON = JSON.serialize(requestJSONMap);
49
50Map<String, Object> reqObj = new Map<String, Object>();
51reqObj.put('version', '1.0');
52reqObj.put('action', 'updateCustomer');
53reqObj.put('requestJSON', reqJSON);
54
55// Place a request to Breadwinner Global API
56Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);