Java tutorial
/* * Zuora API Reference * # Introduction Welcome to the reference for the Zuora REST API! <a href=\"http://en.wikipedia.org/wiki/REST_API\" target=\"_blank\">REST</a> is a web-service protocol that lends itself to rapid development by using everyday HTTP and JSON technology. The Zuora REST API provides a broad set of operations and resources that: * Enable Web Storefront integration between your websites. * Support self-service subscriber sign-ups and account management. * Process revenue schedules through custom revenue rule models. ## Endpoints The Zuora REST services are provided via the following endpoints. | Service | Base URL for REST Endpoints | |-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Production REST service | https://rest.zuora.com/v1 | | Sandbox REST service | https://rest.apisandbox.zuora.com/v1 | The production service provides access to your live user data. The sandbox environment is a good place to test your code without affecting real-world data. To use it, you must be provisioned with a sandbox tenant - your Zuora representative can help with this if needed. ## Accessing the API If you have a Zuora tenant, you already have access the the API. If you don't have a Zuora tenant, go to <a href=\"https://www.zuora.com/resource/zuora-test-drive\" target=\"_blank\">https://www.zuora.com/resource/zuora-test-drive</a> and sign up for a trial tenant. The tenant comes with seed data, such as a sample product catalog. We recommend that you <a href=\"https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/Manage_Users/Create_an_API_User\" target=\"_blank\">create an API user</a> specifically for making API calls. Don't log in to the Zuora UI with this account. Logging in to the UI enables a security feature that periodically expires the account's password, which may eventually cause authentication failures with the API. Note that a user role does not have write access to Zuora REST services unless it has the API Write Access permission as described in those instructions. # Authentication There are three ways to authenticate: * Use an authorization cookie. The cookie authorizes the user to make calls to the REST API for the duration specified in **Administration > Security Policies > Session timeout**. The cookie expiration time is reset with this duration after every call to the REST API. To obtain a cookie, call the REST `connections` resource with the following API user information: * ID * password * entity Id or entity name (Only for [Zuora Multi-entity](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Multi-entity \"Multi-entity\"). See \"Entity Id and Entity Name\" below for more information.) * Include the following parameters in the request header, which re-authenticates the user with each request: * `apiAccessKeyId` * `apiSecretAccessKey` * `entityId` or `entityName` (Only for [Zuora Multi-entity](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Multi-entity \"Multi-entity\"). See \"Entity Id and Entity Name\" below for more information.) * For CORS-enabled APIs only: Include a 'single-use' token in the request header, which re-authenticates the user with each request. See below for more details. ## Entity Id and Entity Name The `entityId` and `entityName` parameters are only used for [Zuora Multi-entity](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Multi-entity). The `entityId` parameter specifies the Id of the entity that you want to access. The `entityName` parameter specifies the [name of the entity](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Multi-entity/B_Introduction_to_Entity_and_Entity_Hierarchy#Name_and_Display_Name \"Introduction to Entity and Entity Hierarchy\") that you want to access. Note that you must have permission to access the entity. You can get the entity Id and entity name through the REST GET Entities call. You can specify either the `entityId` or `entityName` parameter in the authentication to access and view an entity. * If both `entityId` and `entityName` are specified in the authentication, an error occurs. * If neither `entityId` nor `entityName` is specified in the authentication, you will log in to the entity in which your user account is created. See [API User Authentication](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Multi-entity/A_Overview_of_Multi-entity#API_User_Authentication \"Zuora Multi-entity\") for more information. ## Token Authentication for CORS-Enabled APIs The CORS mechanism enables REST API calls to Zuora to be made directly from your customer's browser, with all credit card and security information transmitted directly to Zuora. This minimizes your PCI compliance burden, allows you to implement advanced validation on your payment forms, and makes your payment forms look just like any other part of your website. For security reasons, instead of using cookies, an API request via CORS uses **tokens** for authentication. The token method of authentication is only designed for use with requests that must originate from your customer's browser; **it should not be considered a replacement to the existing cookie authentication** mechanism. See [Zuora CORS REST ](https://knowledgecenter.zuora.com/DC_Developers/REST_API/A_REST_basics/G_CORS_REST \"Zuora CORS REST\")for details on how CORS works and how you can begin to implement customer calls to the Zuora REST APIs. See [HMAC Signatures](/BC_Developers/REST_API/B_REST_API_reference/HMAC_Signatures \"HMAC Signatures\") for details on the HMAC method that returns the authentication token. # Requests and Responses ## Request IDs As a general rule, when asked to supply a \"key\" for an account or subscription (accountKey, account-key, subscriptionKey, subscription-key), you can provide either the actual ID or the number of the entity. ## HTTP Request Body Most of the parameters and data accompanying your requests will be contained in the body of the HTTP request. The Zuora REST API accepts JSON in the HTTP request body. No other data format (e.g., XML) is supported. ## Testing a Request Use a third party client, such as Postman or Advanced REST Client, to test the Zuora REST API. You can test the Zuora REST API from the Zuora sandbox or production service. If connecting to the production service, bear in mind that you are working with your live production data, not sample data or test data. ## Testing with Credit Cards Sooner or later it will probably be necessary to test some transactions that involve credit cards. For suggestions on how to handle this, see [Going Live With Your Payment Gateway](https://knowledgecenter.zuora.com/CB_Billing/M_Payment_Gateways/C_Managing_Payment_Gateways/B_Going_Live_Payment_Gateways#Testing_with_Credit_Cards \"C_Zuora_User_Guides/A_Billing_and_Payments/M_Payment_Gateways/C_Managing_Payment_Gateways/B_Going_Live_Payment_Gateways#Testing_with_Credit_Cards\"). ## Error Handling Responses and error codes are detailed in [Responses and errors](https://knowledgecenter.zuora.com/DC_Developers/REST_API/A_REST_basics/3_Responses_and_errors \"Responses and errors\"). # Pagination When retrieving information (using GET methods), the optional `pageSize` query parameter sets the maximum number of rows to return in a response. The maximum is `40`; larger values are treated as `40`. If this value is empty or invalid, `pageSize` typically defaults to `10`. The default value for the maximum number of rows retrieved can be overridden at the method level. If more rows are available, the response will include a `nextPage` element, which contains a URL for requesting the next page. If this value is not provided, no more rows are available. No \"previous page\" element is explicitly provided; to support backward paging, use the previous call. ## Array Size For data items that are not paginated, the REST API supports arrays of up to 300 rows. Thus, for instance, repeated pagination can retrieve thousands of customer accounts, but within any account an array of no more than 300 rate plans is returned. # API Versions The Zuora REST API is in version control. Versioning ensures that Zuora REST API changes are backward compatible. Zuora uses a major and minor version nomenclature to manage changes. By specifying a version in a REST request, you can get expected responses regardless of future changes to the API. ## Major Version The major version number of the REST API appears in the REST URL. Currently, Zuora only supports the **v1** major version. For example, `POST https://rest.zuora.com/v1/subscriptions` . ## Minor Version Zuora uses minor versions for the REST API to control small changes. For example, a field in a REST method is deprecated and a new field is used to replace it. Some fields in the REST methods are supported as of minor versions. If a field is not noted with a minor version, this field is available for all minor versions. If a field is noted with a minor version, this field is in version control. You must specify the supported minor version in the request header to process without an error. If a field is in version control, it is either with a minimum minor version or a maximum minor version, or both of them. You can only use this field with the minor version between the minimum and the maximum minor versions. For example, the `invoiceCollect` field in the POST Subscription method is in version control and its maximum minor version is 189.0. You can only use this field with the minor version 189.0 or earlier. The supported minor versions are not serial, see [Zuora REST API Minor Version History](https://knowledgecenter.zuora.com/DC_Developers/REST_API/A_REST_basics/Zuora_REST_API_Minor_Version_History \"Zuora REST API Minor Version History\") for the fields and their supported minor versions. In our REST API documentation, if a field or feature requires a minor version number, we note that in the field description. You only need to specify the version number when you use the fields require a minor version. To specify the minor version, set the `zuora-version` parameter to the minor version number in the request header for the request call. For example, the `collect` field is in 196.0 minor version. If you want to use this field for the POST Subscription method, set the `zuora-version` parameter to `196.0` in the request header. The `zuora-version` parameter is case sensitive. For all the REST API fields, by default, if the minor version is not specified in the request header, Zuora will use the minimum minor version of the REST API to avoid breaking your integration. # Zuora Object Model The following diagram presents a high-level view of the key Zuora objects. Click the image to open it in a new tab to resize it. <a href=\"https://www.zuora.com/wp-content/uploads/2016/10/ZuoraERD-compressor-1.jpeg\" target=\"_blank\"><img src=\"https://www.zuora.com/wp-content/uploads/2016/10/ZuoraERD-compressor-1.jpeg\" alt=\"Zuora Object Model Diagram\"></a> * * OpenAPI spec version: 0.0.1 * Contact: docs@zuora.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.swagger.client.api; import io.swagger.client.ApiCallback; import io.swagger.client.ApiClient; import io.swagger.client.ApiException; import io.swagger.client.ApiResponse; import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.ProgressRequestBody; import io.swagger.client.ProgressResponseBody; import com.google.gson.reflect.TypeToken; import java.io.IOException; import io.swagger.client.model.CommonResponseType; import io.swagger.client.model.GETAccountingCodeItemType; import io.swagger.client.model.GETAccountingCodesType; import io.swagger.client.model.POSTAccountingCodeType; import io.swagger.client.model.POSTAccountingCodeResponseType; import io.swagger.client.model.PUTAccountingCodeType; import io.swagger.client.model.ProxyDeleteResponse; import io.swagger.client.model.ProxyGetAccountingCode; import io.swagger.client.model.ProxyNoDataResponse; import io.swagger.client.model.ProxyCreateAccountingCode; import io.swagger.client.model.ProxyCreateOrModifyResponse; import io.swagger.client.model.ProxyBadRequestResponse; import io.swagger.client.model.ProxyModifyAccountingCode; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class AccountingCodesApi { private ApiClient apiClient; public AccountingCodesApi() { this(Configuration.getDefaultApiClient()); } public AccountingCodesApi(ApiClient apiClient) { this.apiClient = apiClient; } public ApiClient getApiClient() { return apiClient; } public void setApiClient(ApiClient apiClient) { this.apiClient = apiClient; } /* Build call for dELETEAccountingCode */ private com.squareup.okhttp.Call dELETEAccountingCodeCall(String acId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'acId' is set if (acId == null) { throw new ApiException( "Missing the required parameter 'acId' when calling dELETEAccountingCode(Async)"); } // create path and map variables String localVarPath = "/accounting-codes/{ac-id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "ac-id" + "\\}", apiClient.escapeString(acId.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[] {}; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Delete accounting code * This reference describes how to [delete an accounting code](https://knowledgecenter.zuora.com/CC_Finance/A_Z-Finance/G_Chart_of_Accounts/A_Set_Up_Chart_of_Accounts#Delete_an_Accounting_Code) through the REST API. ## Prerequisites If you have Z-Finance enabled on your tenant, then you must have the Z-Finance Delete Unused Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). ## Limitations You can only delete accounting codes that have never been associated with any transactions. An accounting code must be deactivated before you can delete it. * @param acId ID of the accounting code you want to delete. (required) * @return CommonResponseType * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public CommonResponseType dELETEAccountingCode(String acId) throws ApiException { ApiResponse<CommonResponseType> resp = dELETEAccountingCodeWithHttpInfo(acId); return resp.getData(); } /** * Delete accounting code * This reference describes how to [delete an accounting code](https://knowledgecenter.zuora.com/CC_Finance/A_Z-Finance/G_Chart_of_Accounts/A_Set_Up_Chart_of_Accounts#Delete_an_Accounting_Code) through the REST API. ## Prerequisites If you have Z-Finance enabled on your tenant, then you must have the Z-Finance Delete Unused Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). ## Limitations You can only delete accounting codes that have never been associated with any transactions. An accounting code must be deactivated before you can delete it. * @param acId ID of the accounting code you want to delete. (required) * @return ApiResponse<CommonResponseType> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<CommonResponseType> dELETEAccountingCodeWithHttpInfo(String acId) throws ApiException { com.squareup.okhttp.Call call = dELETEAccountingCodeCall(acId, null, null); Type localVarReturnType = new TypeToken<CommonResponseType>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Delete accounting code (asynchronously) * This reference describes how to [delete an accounting code](https://knowledgecenter.zuora.com/CC_Finance/A_Z-Finance/G_Chart_of_Accounts/A_Set_Up_Chart_of_Accounts#Delete_an_Accounting_Code) through the REST API. ## Prerequisites If you have Z-Finance enabled on your tenant, then you must have the Z-Finance Delete Unused Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). ## Limitations You can only delete accounting codes that have never been associated with any transactions. An accounting code must be deactivated before you can delete it. * @param acId ID of the accounting code you want to delete. (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call dELETEAccountingCodeAsync(String acId, final ApiCallback<CommonResponseType> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = dELETEAccountingCodeCall(acId, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<CommonResponseType>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for gETAccountingCodeItem */ private com.squareup.okhttp.Call gETAccountingCodeItemCall(String acId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'acId' is set if (acId == null) { throw new ApiException( "Missing the required parameter 'acId' when calling gETAccountingCodeItem(Async)"); } // create path and map variables String localVarPath = "/accounting-codes/{ac-id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "ac-id" + "\\}", apiClient.escapeString(acId.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[] {}; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Query an accounting code * This reference describes how to query an accounting code through the REST API. * @param acId ID of the accounting code you want to query. (required) * @return GETAccountingCodeItemType * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public GETAccountingCodeItemType gETAccountingCodeItem(String acId) throws ApiException { ApiResponse<GETAccountingCodeItemType> resp = gETAccountingCodeItemWithHttpInfo(acId); return resp.getData(); } /** * Query an accounting code * This reference describes how to query an accounting code through the REST API. * @param acId ID of the accounting code you want to query. (required) * @return ApiResponse<GETAccountingCodeItemType> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<GETAccountingCodeItemType> gETAccountingCodeItemWithHttpInfo(String acId) throws ApiException { com.squareup.okhttp.Call call = gETAccountingCodeItemCall(acId, null, null); Type localVarReturnType = new TypeToken<GETAccountingCodeItemType>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Query an accounting code (asynchronously) * This reference describes how to query an accounting code through the REST API. * @param acId ID of the accounting code you want to query. (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call gETAccountingCodeItemAsync(String acId, final ApiCallback<GETAccountingCodeItemType> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = gETAccountingCodeItemCall(acId, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<GETAccountingCodeItemType>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for gETAccountingCodes */ private com.squareup.okhttp.Call gETAccountingCodesCall( final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/accounting-codes".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[] {}; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Get all accounting codes * This reference describes how to query all accounting codes in your chart of accounts through the REST API. * @return GETAccountingCodesType * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public GETAccountingCodesType gETAccountingCodes() throws ApiException { ApiResponse<GETAccountingCodesType> resp = gETAccountingCodesWithHttpInfo(); return resp.getData(); } /** * Get all accounting codes * This reference describes how to query all accounting codes in your chart of accounts through the REST API. * @return ApiResponse<GETAccountingCodesType> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<GETAccountingCodesType> gETAccountingCodesWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = gETAccountingCodesCall(null, null); Type localVarReturnType = new TypeToken<GETAccountingCodesType>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Get all accounting codes (asynchronously) * This reference describes how to query all accounting codes in your chart of accounts through the REST API. * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call gETAccountingCodesAsync(final ApiCallback<GETAccountingCodesType> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = gETAccountingCodesCall(progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<GETAccountingCodesType>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for pOSTAccountingCode */ private com.squareup.okhttp.Call pOSTAccountingCodeCall(POSTAccountingCodeType request, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = request; // verify the required parameter 'request' is set if (request == null) { throw new ApiException( "Missing the required parameter 'request' when calling pOSTAccountingCode(Async)"); } // create path and map variables String localVarPath = "/accounting-codes".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[] {}; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Create accounting code * This reference describes how to create a new accounting code through the REST API. The accounting code will be active as soon as it has been created. ## Prerequisites If you have Z-Finance enabled on your tenant, you must have the Z-Finance Create Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). * @param request (required) * @return POSTAccountingCodeResponseType * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public POSTAccountingCodeResponseType pOSTAccountingCode(POSTAccountingCodeType request) throws ApiException { ApiResponse<POSTAccountingCodeResponseType> resp = pOSTAccountingCodeWithHttpInfo(request); return resp.getData(); } /** * Create accounting code * This reference describes how to create a new accounting code through the REST API. The accounting code will be active as soon as it has been created. ## Prerequisites If you have Z-Finance enabled on your tenant, you must have the Z-Finance Create Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). * @param request (required) * @return ApiResponse<POSTAccountingCodeResponseType> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<POSTAccountingCodeResponseType> pOSTAccountingCodeWithHttpInfo( POSTAccountingCodeType request) throws ApiException { com.squareup.okhttp.Call call = pOSTAccountingCodeCall(request, null, null); Type localVarReturnType = new TypeToken<POSTAccountingCodeResponseType>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Create accounting code (asynchronously) * This reference describes how to create a new accounting code through the REST API. The accounting code will be active as soon as it has been created. ## Prerequisites If you have Z-Finance enabled on your tenant, you must have the Z-Finance Create Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). * @param request (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call pOSTAccountingCodeAsync(POSTAccountingCodeType request, final ApiCallback<POSTAccountingCodeResponseType> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = pOSTAccountingCodeCall(request, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<POSTAccountingCodeResponseType>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for pUTAccountingCode */ private com.squareup.okhttp.Call pUTAccountingCodeCall(String acId, PUTAccountingCodeType request, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = request; // verify the required parameter 'acId' is set if (acId == null) { throw new ApiException("Missing the required parameter 'acId' when calling pUTAccountingCode(Async)"); } // verify the required parameter 'request' is set if (request == null) { throw new ApiException( "Missing the required parameter 'request' when calling pUTAccountingCode(Async)"); } // create path and map variables String localVarPath = "/accounting-codes/{ac-id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "ac-id" + "\\}", apiClient.escapeString(acId.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[] {}; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Update an accounting code * This reference describes how to update an existing accounting code through the REST API. ## Prerequisites If you have Z-Finance enabled on your tenant, you must have the Z-Finance Manage Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). ## Limitations You can only update accounting codes that are not already associated with any transactions. * @param acId ID of the accounting code you want to update. (required) * @param request (required) * @return CommonResponseType * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public CommonResponseType pUTAccountingCode(String acId, PUTAccountingCodeType request) throws ApiException { ApiResponse<CommonResponseType> resp = pUTAccountingCodeWithHttpInfo(acId, request); return resp.getData(); } /** * Update an accounting code * This reference describes how to update an existing accounting code through the REST API. ## Prerequisites If you have Z-Finance enabled on your tenant, you must have the Z-Finance Manage Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). ## Limitations You can only update accounting codes that are not already associated with any transactions. * @param acId ID of the accounting code you want to update. (required) * @param request (required) * @return ApiResponse<CommonResponseType> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<CommonResponseType> pUTAccountingCodeWithHttpInfo(String acId, PUTAccountingCodeType request) throws ApiException { com.squareup.okhttp.Call call = pUTAccountingCodeCall(acId, request, null, null); Type localVarReturnType = new TypeToken<CommonResponseType>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Update an accounting code (asynchronously) * This reference describes how to update an existing accounting code through the REST API. ## Prerequisites If you have Z-Finance enabled on your tenant, you must have the Z-Finance Manage Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). ## Limitations You can only update accounting codes that are not already associated with any transactions. * @param acId ID of the accounting code you want to update. (required) * @param request (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call pUTAccountingCodeAsync(String acId, PUTAccountingCodeType request, final ApiCallback<CommonResponseType> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = pUTAccountingCodeCall(acId, request, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<CommonResponseType>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for pUTActivateAccountingCode */ private com.squareup.okhttp.Call pUTActivateAccountingCodeCall(String acId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'acId' is set if (acId == null) { throw new ApiException( "Missing the required parameter 'acId' when calling pUTActivateAccountingCode(Async)"); } // create path and map variables String localVarPath = "/accounting-codes/{ac-id}/activate".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "ac-id" + "\\}", apiClient.escapeString(acId.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[] {}; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Activate accounting code * This reference describes how to [activate an accounting code](https://knowledgecenter.zuora.com/CC_Finance/A_Z-Finance/G_Chart_of_Accounts/A_Set_Up_Chart_of_Accounts#Activate_or_Deactivate_an_Accounting_Code) through the REST API. Prerequisites ------------- If you have Z-Finance enabled on your tenant, you must have the Z-Finance Manage Accounting Code permission. See [Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). * @param acId ID of the accounting code you want to activate. (required) * @return CommonResponseType * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public CommonResponseType pUTActivateAccountingCode(String acId) throws ApiException { ApiResponse<CommonResponseType> resp = pUTActivateAccountingCodeWithHttpInfo(acId); return resp.getData(); } /** * Activate accounting code * This reference describes how to [activate an accounting code](https://knowledgecenter.zuora.com/CC_Finance/A_Z-Finance/G_Chart_of_Accounts/A_Set_Up_Chart_of_Accounts#Activate_or_Deactivate_an_Accounting_Code) through the REST API. Prerequisites ------------- If you have Z-Finance enabled on your tenant, you must have the Z-Finance Manage Accounting Code permission. See [Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). * @param acId ID of the accounting code you want to activate. (required) * @return ApiResponse<CommonResponseType> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<CommonResponseType> pUTActivateAccountingCodeWithHttpInfo(String acId) throws ApiException { com.squareup.okhttp.Call call = pUTActivateAccountingCodeCall(acId, null, null); Type localVarReturnType = new TypeToken<CommonResponseType>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Activate accounting code (asynchronously) * This reference describes how to [activate an accounting code](https://knowledgecenter.zuora.com/CC_Finance/A_Z-Finance/G_Chart_of_Accounts/A_Set_Up_Chart_of_Accounts#Activate_or_Deactivate_an_Accounting_Code) through the REST API. Prerequisites ------------- If you have Z-Finance enabled on your tenant, you must have the Z-Finance Manage Accounting Code permission. See [Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). * @param acId ID of the accounting code you want to activate. (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call pUTActivateAccountingCodeAsync(String acId, final ApiCallback<CommonResponseType> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = pUTActivateAccountingCodeCall(acId, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<CommonResponseType>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for pUTDeactivateAccountingCode */ private com.squareup.okhttp.Call pUTDeactivateAccountingCodeCall(String acId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'acId' is set if (acId == null) { throw new ApiException( "Missing the required parameter 'acId' when calling pUTDeactivateAccountingCode(Async)"); } // create path and map variables String localVarPath = "/accounting-codes/{ac-id}/deactivate".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "ac-id" + "\\}", apiClient.escapeString(acId.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[] {}; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Deactivate accounting code * This reference describes how to [deactivate an accounting code](https://knowledgecenter.zuora.com/CC_Finance/A_Z-Finance/G_Chart_of_Accounts/A_Set_Up_Chart_of_Accounts#Activate_or_Deactivate_an_Accounting_Code) through the REST API. ## Prerequisites If you have Z-Finance enabled on your tenant, you must have the Z-Finance Manage Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). ## Limitations You can only deactivate accounting codes that are not associated with any transactions. You cannot disable accounting codes of type AccountsReceivable. * @param acId ID of the accounting code you want to deactivate. (required) * @return CommonResponseType * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public CommonResponseType pUTDeactivateAccountingCode(String acId) throws ApiException { ApiResponse<CommonResponseType> resp = pUTDeactivateAccountingCodeWithHttpInfo(acId); return resp.getData(); } /** * Deactivate accounting code * This reference describes how to [deactivate an accounting code](https://knowledgecenter.zuora.com/CC_Finance/A_Z-Finance/G_Chart_of_Accounts/A_Set_Up_Chart_of_Accounts#Activate_or_Deactivate_an_Accounting_Code) through the REST API. ## Prerequisites If you have Z-Finance enabled on your tenant, you must have the Z-Finance Manage Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). ## Limitations You can only deactivate accounting codes that are not associated with any transactions. You cannot disable accounting codes of type AccountsReceivable. * @param acId ID of the accounting code you want to deactivate. (required) * @return ApiResponse<CommonResponseType> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<CommonResponseType> pUTDeactivateAccountingCodeWithHttpInfo(String acId) throws ApiException { com.squareup.okhttp.Call call = pUTDeactivateAccountingCodeCall(acId, null, null); Type localVarReturnType = new TypeToken<CommonResponseType>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Deactivate accounting code (asynchronously) * This reference describes how to [deactivate an accounting code](https://knowledgecenter.zuora.com/CC_Finance/A_Z-Finance/G_Chart_of_Accounts/A_Set_Up_Chart_of_Accounts#Activate_or_Deactivate_an_Accounting_Code) through the REST API. ## Prerequisites If you have Z-Finance enabled on your tenant, you must have the Z-Finance Manage Accounting Code permission. See [Z-Finance Roles](https://knowledgecenter.zuora.com/CF_Users_and_Administrators/A_Administrator_Settings/User_Roles/f_Finance_Roles). ## Limitations You can only deactivate accounting codes that are not associated with any transactions. You cannot disable accounting codes of type AccountsReceivable. * @param acId ID of the accounting code you want to deactivate. (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call pUTDeactivateAccountingCodeAsync(String acId, final ApiCallback<CommonResponseType> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = pUTDeactivateAccountingCodeCall(acId, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<CommonResponseType>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for proxyDELETEAccountingCode */ private com.squareup.okhttp.Call proxyDELETEAccountingCodeCall(String 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 proxyDELETEAccountingCode(Async)"); } // create path and map variables String localVarPath = "/object/accounting-code/{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[] {}; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * CRUD: Delete AccountingCode * * @param id Object id (required) * @return ProxyDeleteResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ProxyDeleteResponse proxyDELETEAccountingCode(String id) throws ApiException { ApiResponse<ProxyDeleteResponse> resp = proxyDELETEAccountingCodeWithHttpInfo(id); return resp.getData(); } /** * CRUD: Delete AccountingCode * * @param id Object id (required) * @return ApiResponse<ProxyDeleteResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<ProxyDeleteResponse> proxyDELETEAccountingCodeWithHttpInfo(String id) throws ApiException { com.squareup.okhttp.Call call = proxyDELETEAccountingCodeCall(id, null, null); Type localVarReturnType = new TypeToken<ProxyDeleteResponse>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * CRUD: Delete AccountingCode (asynchronously) * * @param id Object id (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call proxyDELETEAccountingCodeAsync(String id, final ApiCallback<ProxyDeleteResponse> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = proxyDELETEAccountingCodeCall(id, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<ProxyDeleteResponse>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for proxyGETAccountingCode */ private com.squareup.okhttp.Call proxyGETAccountingCodeCall(String id, String fields, 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 proxyGETAccountingCode(Async)"); } // create path and map variables String localVarPath = "/object/accounting-code/{id}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); List<Pair> localVarQueryParams = new ArrayList<Pair>(); if (fields != null) localVarQueryParams.addAll(apiClient.parameterToPairs("", "fields", fields)); 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[] {}; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * CRUD: Retrieve AccountingCode * * @param id Object id (required) * @param fields Object fields to return (optional) * @return ProxyGetAccountingCode * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ProxyGetAccountingCode proxyGETAccountingCode(String id, String fields) throws ApiException { ApiResponse<ProxyGetAccountingCode> resp = proxyGETAccountingCodeWithHttpInfo(id, fields); return resp.getData(); } /** * CRUD: Retrieve AccountingCode * * @param id Object id (required) * @param fields Object fields to return (optional) * @return ApiResponse<ProxyGetAccountingCode> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<ProxyGetAccountingCode> proxyGETAccountingCodeWithHttpInfo(String id, String fields) throws ApiException { com.squareup.okhttp.Call call = proxyGETAccountingCodeCall(id, fields, null, null); Type localVarReturnType = new TypeToken<ProxyGetAccountingCode>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * CRUD: Retrieve AccountingCode (asynchronously) * * @param id Object id (required) * @param fields Object fields to return (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call proxyGETAccountingCodeAsync(String id, String fields, final ApiCallback<ProxyGetAccountingCode> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = proxyGETAccountingCodeCall(id, fields, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<ProxyGetAccountingCode>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for proxyPOSTAccountingCode */ private com.squareup.okhttp.Call proxyPOSTAccountingCodeCall(ProxyCreateAccountingCode createRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = createRequest; // verify the required parameter 'createRequest' is set if (createRequest == null) { throw new ApiException( "Missing the required parameter 'createRequest' when calling proxyPOSTAccountingCode(Async)"); } // create path and map variables String localVarPath = "/object/accounting-code".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[] {}; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * CRUD: Create AccountingCode * * @param createRequest (required) * @return ProxyCreateOrModifyResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ProxyCreateOrModifyResponse proxyPOSTAccountingCode(ProxyCreateAccountingCode createRequest) throws ApiException { ApiResponse<ProxyCreateOrModifyResponse> resp = proxyPOSTAccountingCodeWithHttpInfo(createRequest); return resp.getData(); } /** * CRUD: Create AccountingCode * * @param createRequest (required) * @return ApiResponse<ProxyCreateOrModifyResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<ProxyCreateOrModifyResponse> proxyPOSTAccountingCodeWithHttpInfo( ProxyCreateAccountingCode createRequest) throws ApiException { com.squareup.okhttp.Call call = proxyPOSTAccountingCodeCall(createRequest, null, null); Type localVarReturnType = new TypeToken<ProxyCreateOrModifyResponse>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * CRUD: Create AccountingCode (asynchronously) * * @param createRequest (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call proxyPOSTAccountingCodeAsync(ProxyCreateAccountingCode createRequest, final ApiCallback<ProxyCreateOrModifyResponse> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = proxyPOSTAccountingCodeCall(createRequest, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<ProxyCreateOrModifyResponse>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for proxyPUTAccountingCode */ private com.squareup.okhttp.Call proxyPUTAccountingCodeCall(String id, ProxyModifyAccountingCode modifyRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = modifyRequest; // verify the required parameter 'id' is set if (id == null) { throw new ApiException( "Missing the required parameter 'id' when calling proxyPUTAccountingCode(Async)"); } // verify the required parameter 'modifyRequest' is set if (modifyRequest == null) { throw new ApiException( "Missing the required parameter 'modifyRequest' when calling proxyPUTAccountingCode(Async)"); } // create path and map variables String localVarPath = "/object/accounting-code/{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[] {}; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * CRUD: Update AccountingCode * * @param id Object id (required) * @param modifyRequest (required) * @return ProxyCreateOrModifyResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ProxyCreateOrModifyResponse proxyPUTAccountingCode(String id, ProxyModifyAccountingCode modifyRequest) throws ApiException { ApiResponse<ProxyCreateOrModifyResponse> resp = proxyPUTAccountingCodeWithHttpInfo(id, modifyRequest); return resp.getData(); } /** * CRUD: Update AccountingCode * * @param id Object id (required) * @param modifyRequest (required) * @return ApiResponse<ProxyCreateOrModifyResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<ProxyCreateOrModifyResponse> proxyPUTAccountingCodeWithHttpInfo(String id, ProxyModifyAccountingCode modifyRequest) throws ApiException { com.squareup.okhttp.Call call = proxyPUTAccountingCodeCall(id, modifyRequest, null, null); Type localVarReturnType = new TypeToken<ProxyCreateOrModifyResponse>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * CRUD: Update AccountingCode (asynchronously) * * @param id Object id (required) * @param modifyRequest (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public com.squareup.okhttp.Call proxyPUTAccountingCodeAsync(String id, ProxyModifyAccountingCode modifyRequest, final ApiCallback<ProxyCreateOrModifyResponse> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { callback.onDownloadProgress(bytesRead, contentLength, done); } }; progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { @Override public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { callback.onUploadProgress(bytesWritten, contentLength, done); } }; } com.squareup.okhttp.Call call = proxyPUTAccountingCodeCall(id, modifyRequest, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<ProxyCreateOrModifyResponse>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } }