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:cloud.artik.api.DevicesManagementApi.java

License:Apache License

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

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

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

From source file:cloud.artik.api.DevicesManagementApi.java

License:Apache License

private com.squareup.okhttp.Call getAllByDidCall(String did, Integer count, Integer offset, String status,
        String order, String sort, final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

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

    // create path and map variables
    String localVarPath = "/devicemgmt/devices/{did}/tasks".replaceAll("\\{format\\}", "json")
            .replaceAll("\\{" + "did" + "\\}", apiClient.escapeString(did.toString()));

    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    if (count != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "count", count));
    if (offset != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));
    if (status != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status));
    if (order != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "order", order));
    if (sort != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort", sort));

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

From source file:cloud.artik.api.DevicesManagementApi.java

License:Apache License

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

    // verify the required parameter 'dtid' is set
    if (dtid == null) {
        throw new ApiException("Missing the required parameter 'dtid' when calling getDeviceTypesInfo(Async)");
    }//from   w w  w  .  java 2s .  c  om

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

From source file:cloud.artik.api.DevicesManagementApi.java

License:Apache License

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

    // verify the required parameter 'dtid' is set
    if (dtid == null) {
        throw new ApiException(
                "Missing the required parameter 'dtid' when calling getManifestProperties(Async)");
    }//from  ww  w .ja  va2  s  .c  o m

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

From source file:cloud.artik.api.DevicesManagementApi.java

License:Apache License

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

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

    // create path and map variables
    String localVarPath = "/devicemgmt/devices/{did}/properties".replaceAll("\\{format\\}", "json")
            .replaceAll("\\{" + "did" + "\\}", apiClient.escapeString(did.toString()));

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

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

From source file:cloud.artik.api.DevicesManagementApi.java

License:Apache License

private com.squareup.okhttp.Call getStatusesCall(String tid, Integer count, Integer offset, String status,
        String dids, final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

    // verify the required parameter 'tid' is set
    if (tid == null) {
        throw new ApiException("Missing the required parameter 'tid' when calling getStatuses(Async)");
    }//from   w w w  .  jav a2s.  com

    // create path and map variables
    String localVarPath = "/devicemgmt/tasks/{tid}/statuses".replaceAll("\\{format\\}", "json")
            .replaceAll("\\{" + "tid" + "\\}", apiClient.escapeString(tid.toString()));

    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    if (count != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "count", count));
    if (offset != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));
    if (status != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status));
    if (dids != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "dids", dids));

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

From source file:cloud.artik.api.DevicesManagementApi.java

License:Apache License

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

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

    // create path and map variables
    String localVarPath = "/devicemgmt/tasks/{tid}/statuses/history".replaceAll("\\{format\\}", "json")
            .replaceAll("\\{" + "tid" + "\\}", apiClient.escapeString(tid.toString()));

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

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

From source file:cloud.artik.api.DevicesManagementApi.java

License:Apache License

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

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

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

From source file:cloud.artik.api.DevicesManagementApi.java

License:Apache License

private com.squareup.okhttp.Call getTasksCall(String dtid, Integer count, Integer offset, String status,
        String order, String sort, final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

    // verify the required parameter 'dtid' is set
    if (dtid == null) {
        throw new ApiException("Missing the required parameter 'dtid' when calling getTasks(Async)");
    }/*from www. j ava  2 s . com*/

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

    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    if (dtid != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "dtid", dtid));
    if (count != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "count", count));
    if (offset != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));
    if (status != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status));
    if (order != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "order", order));
    if (sort != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort", sort));

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

From source file:cloud.artik.api.DevicesManagementApi.java

License:Apache License

private com.squareup.okhttp.Call queryPropertiesCall(String dtid, Integer count, Integer offset, String filter,
        Boolean includeTimestamp, final ProgressResponseBody.ProgressListener progressListener,
        final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;

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

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

    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    if (dtid != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "dtid", dtid));
    if (count != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "count", count));
    if (offset != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));
    if (filter != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter", filter));
    if (includeTimestamp != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "includeTimestamp", includeTimestamp));

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