Global API
...
Request
Purchase Order
Update
1min
To update a PO in Xero, make sure you set the field "PurchaseOrderID" with the unique reference value (ID generated by Xero for the PO)
Request
Response
1// Create a Map to store all the data of a Purchase Order
2List<Object> purchaseOrderList = new List<Object>();
3Map<String, Object> purchaseOrderMap = new Map<String, Object>();
4 purchaseOrderMap.put('DateString', '2021-11-11T00:00:00');
5 purchaseOrderMap.put('DeliveryDate', '2021-12-06T00:00:00');
6 purchaseOrderMap.put('Status', 'AUTHORISED');
7 purchaseOrderMap.put('PurchaseOrderID', '2fef007e-1979-4634-9bb7-87c4559a0038');
8
9 // Initializing the Contact
10 Map<String, Object> contactMap = new Map<String, Object>();
11 contactMap.put('ContactID', 'c84ebb15-0a8d-4145-933f-203e68d014a0');
12 purchaseOrderMap.put('Contact', contactMap);
13 // Initializing the Purchase Order Line Items
14 List<Object> lineItemList = new List<Object>();
15 Map<String, Object> lineItemMap = new Map<String, Object>();
16 lineItemMap.put('Description', 'Line Item Description updated');
17 lineItemMap.put('UnitAmount', 100);
18 lineItemMap.put('Quantity', 10);
19 lineItemMap.put('AccountCode', '310');
20 lineItemMap.put('LineItemID', 'fd9bd48c-9f10-44de-aee4-c6185b2868c3');
21 lineItemList.add(lineItemMap);
22
23 // Adding the Line Items to Purchase Order
24 purchaseOrderMap.put('LineItems', lineItemList);
25 purchaseOrderList.add(purchaseOrderMap);
26
27// Initializing the RequestJSON Data to be passed.
28 Map<String, Object> reqJSONMap = new Map<String, Object>();
29 reqJSONMap.put('purchaseOrders', purchaseOrderList);
30 String reqJSON = JSON.serialize(reqJSONMap);
31
32 Map<String, Object> finalReqMap = new Map<String, Object>();
33 finalReqMap.put('version', '1.0');
34 finalReqMap.put('action', 'updatePurchaseOrder');
35 finalReqMap.put('RequestJSON', reqJSON);
36 finalReqMap.put('skipDML', false);
37 //Required, if Xero Multi-Org is enabled in Breadwinner.
38 finalReqMap.put('xeroOrgId', '!aa00TM');
39 System.debug('Request ::: ' + finalReqMap);
40
41// Placing a request to Breadwinner Global API
42 Map<String, Object> respMap = bread_winner.BreadwinnerXeroAPI.call(finalReqMap);
43 System.debug('Response ::: ' + respMap);