use of com.salesforce.androidsdk.rest.CompositeResponse in project SalesforceMobileSDK-Android by forcedotcom.
the class CompositeRequestHelper method sendCompositeRequest.
/**
* Build and send composite request
* @param syncManager
* @param allOrNone
* @param refIdToRequests
* @return map of ref id to composite sub response
* @throws JSONException
* @throws IOException
*/
public static Map<String, CompositeSubResponse> sendCompositeRequest(SyncManager syncManager, boolean allOrNone, LinkedHashMap<String, RestRequest> refIdToRequests) throws JSONException, IOException {
RestRequest compositeRequest = RestRequest.getCompositeRequest(syncManager.apiVersion, allOrNone, refIdToRequests);
RestResponse response = syncManager.sendSyncWithMobileSyncUserAgent(compositeRequest);
if (!response.isSuccess()) {
throw new SyncManager.MobileSyncException("sendCompositeRequest:" + response.toString());
}
CompositeResponse compositeResponse = new CompositeResponse(response.asJSONObject());
Map<String, CompositeSubResponse> refIdToResponses = new HashMap<>();
for (CompositeSubResponse subResponse : compositeResponse.subResponses) {
refIdToResponses.put(subResponse.referenceId, subResponse);
}
return refIdToResponses;
}
Aggregations