Example usage for com.squareup.okhttp Response body

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

Introduction

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

Prototype

ResponseBody body

To view the source code for com.squareup.okhttp Response body.

Click Source Link

Usage

From source file:co.uk.crowdemotion.TimeseriesApi.java

License:Apache License

private com.squareup.okhttp.Call timeseriesGetCall(Integer responseId, Integer metricId, Boolean normalize,
        String format, final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

    // verify the required parameter 'responseId' is set
    if (responseId == null) {
        throw new ApiException("Missing the required parameter 'responseId' when calling timeseriesGet(Async)");
    }/*from   w  ww .  j  ava  2s . c o m*/

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

    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    if (responseId != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "response_id", responseId));
    if (metricId != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "metric_id", metricId));
    if (normalize != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "normalize", normalize));
    if (format != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "format", format));

    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
            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[] { "api_key" };
    return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
            localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:co.uk.crowdemotion.UserApi.java

License:Apache License

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

    // verify the required parameter 'id' is set
    if (id == null) {
        throw new ApiException("Missing the required parameter 'id' when calling userIdGet(Async)");
    }/*from  ww  w  .  j  ava 2 s  .  c  om*/

    // create path and map variables
    String localVarPath = "/user/{id}".replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}",
            apiClient.escapeString(id.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 = { "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
            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[] { "api_key" };
    return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
            localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:co.uk.crowdemotion.UserApi.java

License:Apache License

private com.squareup.okhttp.Call userIdPutCall(String id, UserUpdateBody body,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = body;

    // verify the required parameter 'id' is set
    if (id == null) {
        throw new ApiException("Missing the required parameter 'id' when calling userIdPut(Async)");
    }// w  w w.jav a2 s.c om

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

    // create path and map variables
    String localVarPath = "/user/{id}".replaceAll("\\{format\\}", "json").replaceAll("\\{" + "id" + "\\}",
            apiClient.escapeString(id.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 = { "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
            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[] { "api_key" };
    return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams,
            localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:co.uk.crowdemotion.UserApi.java

License:Apache License

private com.squareup.okhttp.Call userLoginPostCall(Login body,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = body;

    // verify the required parameter 'body' is set
    if (body == null) {
        throw new ApiException("Missing the required parameter 'body' when calling userLoginPost(Async)");
    }/*from  w  ww  .j  a va 2s .  co m*/

    // create path and map variables
    String localVarPath = "/user/login".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 = { "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
            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[] { "api_key" };
    return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
            localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:co.uk.crowdemotion.UserApi.java

License:Apache License

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

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

    // create path and map variables
    String localVarPath = "/user/{user_id}/metadata".replaceAll("\\{format\\}", "json")
            .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.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 = { "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
            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[] { "api_key" };
    return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
            localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:co.uk.crowdemotion.UserApi.java

License:Apache License

private com.squareup.okhttp.Call userUserIdMetadataPostCall(Integer userId, UserMetadata body,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = body;

    // verify the required parameter 'userId' is set
    if (userId == null) {
        throw new ApiException(
                "Missing the required parameter 'userId' when calling userUserIdMetadataPost(Async)");
    }//from w  w w .j a v a2 s .  c  o m

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

    // create path and map variables
    String localVarPath = "/user/{user_id}/metadata".replaceAll("\\{format\\}", "json")
            .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.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 = { "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
            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[] { "api_key" };
    return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
            localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}

From source file:co.waitlisted.api.ReservationApi.java

License:Apache License

private com.squareup.okhttp.Call activateReservationCall(ReservationRequest body,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object wllocalVarPostBody = body;

    // verify the required parameter 'body' is set
    if (body == null) {
        throw new ApiException("Missing the required parameter 'body' when calling activateReservation(Async)");
    }//from  w ww .  ja  v  a2 s.c om

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

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

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

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

    final String[] wllocalVarAccepts = { "application/json" };
    final String wllocalVarAccept = wlapiClient.selectHeaderAccept(wllocalVarAccepts);
    if (wllocalVarAccept != null)
        wllocalVarHeaderParams.put("Accept", wllocalVarAccept);

    final String[] wllocalVarContentTypes = { "application/json" };
    final String wllocalVarContentType = wlapiClient.selectHeaderContentType(wllocalVarContentTypes);
    wllocalVarHeaderParams.put("Content-Type", wllocalVarContentType);

    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[] wllocalVarAuthNames = new String[] { "api_key" };
    return wlapiClient.buildCall(wllocalVarPath, "POST", wllocalVarQueryParams, wllocalVarPostBody,
            wllocalVarHeaderParams, wllocalVarFormParams, wllocalVarAuthNames, progressRequestListener);
}

From source file:co.waitlisted.api.ReservationApi.java

License:Apache License

private com.squareup.okhttp.Call createReservationCall(Reservation body,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object wllocalVarPostBody = body;

    // verify the required parameter 'body' is set
    if (body == null) {
        throw new ApiException("Missing the required parameter 'body' when calling createReservation(Async)");
    }/*from w  w w  .  j  av a2s.  c  o  m*/

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

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

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

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

    final String[] wllocalVarAccepts = { "application/json" };
    final String wllocalVarAccept = wlapiClient.selectHeaderAccept(wllocalVarAccepts);
    if (wllocalVarAccept != null)
        wllocalVarHeaderParams.put("Accept", wllocalVarAccept);

    final String[] wllocalVarContentTypes = { "application/json" };
    final String wllocalVarContentType = wlapiClient.selectHeaderContentType(wllocalVarContentTypes);
    wllocalVarHeaderParams.put("Content-Type", wllocalVarContentType);

    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[] wllocalVarAuthNames = new String[] {};
    return wlapiClient.buildCall(wllocalVarPath, "POST", wllocalVarQueryParams, wllocalVarPostBody,
            wllocalVarHeaderParams, wllocalVarFormParams, wllocalVarAuthNames, progressRequestListener);
}

From source file:co.waitlisted.api.ReservationApi.java

License:Apache License

private com.squareup.okhttp.Call deleteReservationCall(ReservationRequest body,
        final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object wllocalVarPostBody = body;

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

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

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

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

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

    final String[] wllocalVarAccepts = { "application/json" };
    final String wllocalVarAccept = wlapiClient.selectHeaderAccept(wllocalVarAccepts);
    if (wllocalVarAccept != null)
        wllocalVarHeaderParams.put("Accept", wllocalVarAccept);

    final String[] wllocalVarContentTypes = { "application/json" };
    final String wllocalVarContentType = wlapiClient.selectHeaderContentType(wllocalVarContentTypes);
    wllocalVarHeaderParams.put("Content-Type", wllocalVarContentType);

    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[] wllocalVarAuthNames = new String[] { "api_key" };
    return wlapiClient.buildCall(wllocalVarPath, "DELETE", wllocalVarQueryParams, wllocalVarPostBody,
            wllocalVarHeaderParams, wllocalVarFormParams, wllocalVarAuthNames, progressRequestListener);
}

From source file:co.waitlisted.api.ReservationApi.java

License:Apache License

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

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

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

    List<Pair> wllocalVarQueryParams = new ArrayList<Pair>();
    if (email != null)
        wllocalVarQueryParams.addAll(wlapiClient.parameterToPairs("", "email", email));

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

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

    final String[] wllocalVarAccepts = { "application/json" };
    final String wllocalVarAccept = wlapiClient.selectHeaderAccept(wllocalVarAccepts);
    if (wllocalVarAccept != null)
        wllocalVarHeaderParams.put("Accept", wllocalVarAccept);

    final String[] wllocalVarContentTypes = { "application/json" };
    final String wllocalVarContentType = wlapiClient.selectHeaderContentType(wllocalVarContentTypes);
    wllocalVarHeaderParams.put("Content-Type", wllocalVarContentType);

    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[] wllocalVarAuthNames = new String[] {};
    return wlapiClient.buildCall(wllocalVarPath, "GET", wllocalVarQueryParams, wllocalVarPostBody,
            wllocalVarHeaderParams, wllocalVarFormParams, wllocalVarAuthNames, progressRequestListener);
}