Global API
...
Request
Contact
Create
1min
The following is an example to create a Customer with every possible field available (See Contact for the available fields)
Request
Response
1// Create a Map to store all the data of a Contact
2Map<String, Object> contactMap = new Map<String, Object>();
3 contactMap.put('Name', 'Breadwinner Inc');
4 contactMap.put('FirstName', 'Jack');
5 contactMap.put('LastName', 'Rogers');
6 contactMap.put('EmailAddress', '[email protected]');
7
8 List<Object> phonesList = new List<Object>();
9 Map<String, Object> DefaultPhone = new Map<String, Object>();
10 DefaultPhone.put('PhoneType', 'DEFAULT');
11 DefaultPhone.put('PhoneNumber', '9988543562');
12 phonesList.add(DefaultPhone);
13 contactMap.put('Phones', phonesList);
14
15 List<Object> addressList = new List<Object>();
16 Map<String, Object> shippingAddressMap = new Map<String, Object>();
17 shippingAddressMap.put('AddressType', 'STREET');
18 shippingAddressMap.put('Country', 'India');
19 shippingAddressMap.put('AddressLine3', 'Kodad');
20 shippingAddressMap.put('AddressLine2', 'First Lane');
21 shippingAddressMap.put('AddressLine1', '1-24');
22 shippingAddressMap.put('PostalCode', '508238');
23 shippingAddressMap.put('City', 'Suryapet');
24 shippingAddressMap.put('Region', 'India');
25 shippingAddressMap.put('AttentionTo', 'User');
26 addressList.add(shippingAddressMap);
27
28 Map<String, Object> billingAddrFieldMap = new Map<String, Object>();
29 billingAddrFieldMap.put('AddressType', 'POBOX');
30 billingAddrFieldMap.put('Country', 'India');
31 billingAddrFieldMap.put('AddressLine3', '');
32 billingAddrFieldMap.put('AddressLine2', 'Srinagar Colony');
33 billingAddrFieldMap.put('AddressLine1', '1/78-24');
34 billingAddrFieldMap.put('PostalCode', '500008');
35 billingAddrFieldMap.put('City', 'Hyderabad');
36 billingAddrFieldMap.put('Region', 'India');
37 billingAddrFieldMap.put('AttentionTo', 'User');
38 addressList.add(billingAddrFieldMap);
39
40 contactMap.put('Addresses', addressList);
41
42// Initializing the RequestJSON Data to be passed.
43Map<String, Object> requestJSONMap = new Map<String, Object>();
44 requestJSONMap.put('contacts', new List<Object>{contactMap});
45 String reqJSON = JSON.serialize(requestJSONMap);
46
47Map<String, Object> reqObj = new Map<String, Object>();
48 reqObj.put('version', '1.0');
49 reqObj.put('action', 'createContact');
50 reqObj.put('requestJSON', reqJSON);
51 //Required, if Xero Multi-Org is enabled in Breadwinner.
52 reqObj.put('xeroOrgId', '!aa00TM');
53
54// Placing a request to Breadwinner Global API
55Map<String, Object> respMap = bread_winner.BreadwinnerXeroAPI.call(reqObj);
56System.debug(respMap);