Search in sources :

Example 1 with CompositeResponse

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;
}
Also used : RestRequest(com.salesforce.androidsdk.rest.RestRequest) CompositeResponse(com.salesforce.androidsdk.rest.CompositeResponse) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) RestResponse(com.salesforce.androidsdk.rest.RestResponse) CompositeSubResponse(com.salesforce.androidsdk.rest.CompositeResponse.CompositeSubResponse)

Aggregations

CompositeResponse (com.salesforce.androidsdk.rest.CompositeResponse)1 CompositeSubResponse (com.salesforce.androidsdk.rest.CompositeResponse.CompositeSubResponse)1 RestRequest (com.salesforce.androidsdk.rest.RestRequest)1 RestResponse (com.salesforce.androidsdk.rest.RestResponse)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1