Example usage for com.squareup.okhttp Response newBuilder

List of usage examples for com.squareup.okhttp Response newBuilder

Introduction

In this page you can find the example usage for com.squareup.okhttp Response newBuilder.

Prototype

public Builder newBuilder() 

Source Link

Usage

From source file:com.mallorcasoftware.openweatherclient.api.DefaultApi.java

License:Apache License

private com.squareup.okhttp.Call getCurrentWeatherDataCall(String q, String id, String units, String lang,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

    // create path and map variables
    String localVarPath = "/weather".replaceAll("\\{format\\}", "json");

    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    if (q != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "q", q));
    if (id != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "id", id));
    if (units != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "units", units));
    if (lang != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "lang", lang));

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = { "application/json" };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null)
        localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = { "application/json" };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    if (progressListener != null) {
        apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
            @Override// w  ww. j a  va2s .  c  o  m
            public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                    throws IOException {
                com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                return originalResponse.newBuilder()
                        .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
            }
        });
    }

    String[] localVarAuthNames = new String[] { "UserSecurity" };
    return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
            localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:com.mallorcasoftware.openweatherclient.api.DefaultApi.java

License:Apache License

private com.squareup.okhttp.Call getForecastCall(String q, String id, String units, String lang,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

    // create path and map variables
    String localVarPath = "/forecast".replaceAll("\\{format\\}", "json");

    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    if (q != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "q", q));
    if (id != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "id", id));
    if (units != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "units", units));
    if (lang != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "lang", lang));

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = { "application/json" };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null)
        localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = { "application/json" };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    if (progressListener != null) {
        apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
            @Override//ww  w . j  a  va 2 s.c o m
            public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                    throws IOException {
                com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                return originalResponse.newBuilder()
                        .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
            }
        });
    }

    String[] localVarAuthNames = new String[] { "UserSecurity" };
    return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
            localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:com.microsoft.identity.internal.test.labapi.api.DefaultApi.java

/**
 * Build call for getTestConfiguration//from   w  ww.  java  2  s.  co m
 * @param appName Name of an application (optional)
 * @param appId App ID (optional)
 * @param federationProvider Match string search for federation provider name (optional)
 * @param mfa Whether or not MFA is enabled for the user (optional)
 * @param mam Whether or not MAM policy has been applied to the user (optional)
 * @param mdm Whether or not MDM policy has been applied to the user (optional)
 * @param ca Whether or not conditional access is enabled? (Weird what does this mean) (optional)
 * @param mamca Whether or not conditional access requiring a MAM enabled client was applied? (Weird what does this mean) (optional)
 * @param mdmca Whether or not conditional access requiring a MDM enrolled device was applied? (Weird what does this mean) (optional)
 * @param license Find a user with a matching license (optional)
 * @param federated Find a federated tenant (optional)
 * @param isFederated Find a federated user (optional)
 * @param userType Find a user who is a member or a guest... by saying which you want (optional)
 * @param role Find a user who is a member of the specified role (optional)
 * @param external Find an external user (optional)
 * @param upn Find an a user by their UPN (optional)
 * @param progressListener Progress listener
 * @param progressRequestListener Progress request listener
 * @return Call to execute
 * @throws ApiException If fail to serialize the request body object
 */
public com.squareup.okhttp.Call getTestConfigurationCall(String appName, String appId,
        String federationProvider, Boolean mfa, Boolean mam, Boolean mdm, Boolean ca, Boolean mamca,
        Boolean mdmca, String license, Boolean federated, Boolean isFederated, String userType, String role,
        Boolean external, String upn, final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

    // create path and map variables
    String localVarPath = "/user";

    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
    if (appName != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("AppName", appName));
    if (appId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("AppId", appId));
    if (federationProvider != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("federationProvider", federationProvider));
    if (mfa != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("mfa", mfa));
    if (mam != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("mam", mam));
    if (mdm != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("mdm", mdm));
    if (ca != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("ca", ca));
    if (mamca != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("mamca", mamca));
    if (mdmca != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("mdmca", mdmca));
    if (license != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("license", license));
    if (federated != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("federated", federated));
    if (isFederated != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("isFederated", isFederated));
    if (userType != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("userType", userType));
    if (role != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("role", role));
    if (external != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("external", external));
    if (upn != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("upn", upn));

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = { "application/json" };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null)
        localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = {

    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    if (progressListener != null) {
        apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
            @Override
            public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                    throws IOException {
                com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                return originalResponse.newBuilder()
                        .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
            }
        });
    }

    String[] localVarAuthNames = new String[] {};
    return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams,
            localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames,
            progressRequestListener);
}

From source file:com.mobimvp.cliques.util.StethoInterceptor.java

License:Apache License

@Override
public Response intercept(Chain chain) throws IOException {
    String requestId = String.valueOf(mNextRequestId.getAndIncrement());
    Request request = chain.request();
    int requestSize = 0;
    if (mEventReporter.isEnabled()) {
        OkHttpInspectorRequest inspectorRequest = new OkHttpInspectorRequest(requestId, request);
        mEventReporter.requestWillBeSent(inspectorRequest);
        byte[] requestBody = inspectorRequest.body();
        if (requestBody != null) {
            requestSize += requestBody.length;
        }/*from ww  w .j av a 2 s . c o  m*/
    }

    Response response;
    try {
        response = chain.proceed(request);
    } catch (IOException e) {
        if (mEventReporter.isEnabled()) {
            mEventReporter.httpExchangeFailed(requestId, e.toString());
        }
        throw e;
    }

    if (mEventReporter.isEnabled()) {
        if (requestSize > 0) {
            mEventReporter.dataSent(requestId, requestSize, requestSize);
        }

        Connection connection = chain.connection();
        mEventReporter
                .responseHeadersReceived(new OkHttpInspectorResponse(requestId, request, response, connection));

        ResponseBody body = response.body();
        MediaType contentType = null;
        InputStream responseStream = null;
        if (body != null) {
            contentType = body.contentType();
            responseStream = body.byteStream();
        }

        responseStream = mEventReporter.interpretResponseStream(requestId,
                contentType != null ? contentType.toString() : null, response.header("Content-Encoding"),
                responseStream, new DefaultResponseHandler(mEventReporter, requestId));
        if (responseStream != null) {
            response = response.newBuilder().body(new ForwardingResponseBody(body, responseStream)).build();
        }
    }

    return response;
}

From source file:com.onfido.api.DefaultApi.java

License:Apache License

private com.squareup.okhttp.Call cancelReportCall(String checkId, String reportId,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

    // verify the required parameter 'checkId' is set
    if (checkId == null) {
        throw new ApiException("Missing the required parameter 'checkId' when calling cancelReport(Async)");
    }// www .j  av  a 2 s  .  c  om

    // verify the required parameter 'reportId' is set
    if (reportId == null) {
        throw new ApiException("Missing the required parameter 'reportId' when calling cancelReport(Async)");
    }

    // create path and map variables
    String localVarPath = "/checks/{check_id}/reports/{report_id}/cancel".replaceAll("\\{format\\}", "json")
            .replaceAll("\\{" + "check_id" + "\\}", apiClient.escapeString(checkId.toString()))
            .replaceAll("\\{" + "report_id" + "\\}", apiClient.escapeString(reportId.toString()));

    List<Pair> localVarQueryParams = new ArrayList<Pair>();

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = { "application/json" };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null)
        localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = {

    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    if (progressListener != null) {
        apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
            @Override
            public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                    throws IOException {
                com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                return originalResponse.newBuilder()
                        .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
            }
        });
    }

    String[] localVarAuthNames = new String[] { "Token" };
    return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
            localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:com.onfido.api.DefaultApi.java

License:Apache License

private com.squareup.okhttp.Call createApplicantCall(Applicant data,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = data;

    // create path and map variables
    String localVarPath = "/applicants".replaceAll("\\{format\\}", "json");

    List<Pair> localVarQueryParams = new ArrayList<Pair>();

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = { "application/json" };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null)
        localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = {

    };/*from   w w  w  .j  av  a  2s  . co m*/
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    if (progressListener != null) {
        apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
            @Override
            public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                    throws IOException {
                com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                return originalResponse.newBuilder()
                        .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
            }
        });
    }

    String[] localVarAuthNames = new String[] { "Token" };
    return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
            localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:com.onfido.api.DefaultApi.java

License:Apache License

private com.squareup.okhttp.Call createCheckCall(String applicantId, CheckCreationRequest data,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = data;

    // verify the required parameter 'applicantId' is set
    if (applicantId == null) {
        throw new ApiException("Missing the required parameter 'applicantId' when calling createCheck(Async)");
    }/*from w  ww.  ja v a  2s .c o  m*/

    // create path and map variables
    String localVarPath = "/applicants/{applicant_id}/checks".replaceAll("\\{format\\}", "json")
            .replaceAll("\\{" + "applicant_id" + "\\}", apiClient.escapeString(applicantId.toString()));

    List<Pair> localVarQueryParams = new ArrayList<Pair>();

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = { "application/json" };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null)
        localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = {

    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    if (progressListener != null) {
        apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
            @Override
            public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                    throws IOException {
                com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                return originalResponse.newBuilder()
                        .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
            }
        });
    }

    String[] localVarAuthNames = new String[] { "Token" };
    return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
            localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:com.onfido.api.DefaultApi.java

License:Apache License

private com.squareup.okhttp.Call createWebhookCall(Webhook data,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = data;

    // create path and map variables
    String localVarPath = "/webhooks".replaceAll("\\{format\\}", "json");

    List<Pair> localVarQueryParams = new ArrayList<Pair>();

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = { "application/json" };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null)
        localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = {

    };/*from w ww.  j  av  a  2 s  .  co m*/
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    if (progressListener != null) {
        apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
            @Override
            public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                    throws IOException {
                com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                return originalResponse.newBuilder()
                        .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
            }
        });
    }

    String[] localVarAuthNames = new String[] { "Token" };
    return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
            localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:com.onfido.api.DefaultApi.java

License:Apache License

private com.squareup.okhttp.Call destroyApplicantCall(String applicantId,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

    // verify the required parameter 'applicantId' is set
    if (applicantId == null) {
        throw new ApiException(
                "Missing the required parameter 'applicantId' when calling destroyApplicant(Async)");
    }//  w  w w.  ja  v a  2 s. c  o m

    // create path and map variables
    String localVarPath = "/applicants/{applicant_id}".replaceAll("\\{format\\}", "json")
            .replaceAll("\\{" + "applicant_id" + "\\}", apiClient.escapeString(applicantId.toString()));

    List<Pair> localVarQueryParams = new ArrayList<Pair>();

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = { "application/json" };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null)
        localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = {

    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    if (progressListener != null) {
        apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
            @Override
            public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                    throws IOException {
                com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                return originalResponse.newBuilder()
                        .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
            }
        });
    }

    String[] localVarAuthNames = new String[] { "Token" };
    return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
            localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:com.onfido.api.DefaultApi.java

License:Apache License

private com.squareup.okhttp.Call downloadDocumentCall(String applicantId, String documentId,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

    // verify the required parameter 'applicantId' is set
    if (applicantId == null) {
        throw new ApiException(
                "Missing the required parameter 'applicantId' when calling downloadDocument(Async)");
    }//from w w w  . j  a  v a  2 s.com

    // verify the required parameter 'documentId' is set
    if (documentId == null) {
        throw new ApiException(
                "Missing the required parameter 'documentId' when calling downloadDocument(Async)");
    }

    // create path and map variables
    String localVarPath = "/applicants/{applicant_id}/documents/{document_id}/download"
            .replaceAll("\\{format\\}", "json")
            .replaceAll("\\{" + "applicant_id" + "\\}", apiClient.escapeString(applicantId.toString()))
            .replaceAll("\\{" + "document_id" + "\\}", apiClient.escapeString(documentId.toString()));

    List<Pair> localVarQueryParams = new ArrayList<Pair>();

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = { "image/png", "image/jpeg", "applicant/pdf" };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null)
        localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = {

    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    if (progressListener != null) {
        apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
            @Override
            public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                    throws IOException {
                com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                return originalResponse.newBuilder()
                        .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
            }
        });
    }

    String[] localVarAuthNames = new String[] { "Token" };
    return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
            localVarFormParams, localVarAuthNames, progressRequestListener);
}