Java tutorial
/** * AHOI API * AHOI (working title) is our managed and flexible banking API designed to offer easy access to your users bank accounts. [AHOI cookbook](/ahoi/docs/cookbook/index.html) [Imprint](https://symbioticon.de/legal-notices/) [Privacy Disclaimer](https://symbioticon.de/data-protection-guidelines/) © 2016 Starfinanz - Ein Unternehmen der Finanz Informatik * * OpenAPI spec version: 2.0.0 * * * 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.Access; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class AccessApi { private ApiClient apiClient; public AccessApi() { this(Configuration.getDefaultApiClient()); } public AccessApi(ApiClient apiClient) { this.apiClient = apiClient; } public ApiClient getApiClient() { return apiClient; } public void setApiClient(ApiClient apiClient) { this.apiClient = apiClient; } /* Build call for deleteAccess */ private com.squareup.okhttp.Call deleteAccessCall(Long accessId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'accessId' is set if (accessId == null) { throw new ApiException("Missing the required parameter 'accessId' when calling deleteAccess(Async)"); } // create path and map variables String localVarPath = "/v2/accesses/{accessId}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "accessId" + "\\}", apiClient.escapeString(accessId.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 = { }; 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[] { "apiKey" }; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Delete access * Delete access with **accessId** and all related accounts. This also deletes related notifications. If this is a user's last remaining access, all notification targets will also be deleted. * @param accessId The **id** for the access to delete (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void deleteAccess(Long accessId) throws ApiException { deleteAccessWithHttpInfo(accessId); } /** * Delete access * Delete access with **accessId** and all related accounts. This also deletes related notifications. If this is a user's last remaining access, all notification targets will also be deleted. * @param accessId The **id** for the access to delete (required) * @return ApiResponse<Void> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<Void> deleteAccessWithHttpInfo(Long accessId) throws ApiException { com.squareup.okhttp.Call call = deleteAccessCall(accessId, null, null); return apiClient.execute(call); } /** * Delete access (asynchronously) * Delete access with **accessId** and all related accounts. This also deletes related notifications. If this is a user's last remaining access, all notification targets will also be deleted. * @param accessId The **id** for the access 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 deleteAccessAsync(Long accessId, final ApiCallback<Void> 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 = deleteAccessCall(accessId, progressListener, progressRequestListener); apiClient.executeAsync(call, callback); return call; } /* Build call for getAccess */ private com.squareup.okhttp.Call getAccessCall(Long accessId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'accessId' is set if (accessId == null) { throw new ApiException("Missing the required parameter 'accessId' when calling getAccess(Async)"); } // create path and map variables String localVarPath = "/v2/accesses/{accessId}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "accessId" + "\\}", apiClient.escapeString(accessId.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[] { "apiKey" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Get access * Retrieve the access with **accessId**. The retrieved object does not contain sensitive information such as the PIN. * @param accessId The **id** for the access to retrieve. (required) * @return Access * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public Access getAccess(Long accessId) throws ApiException { ApiResponse<Access> resp = getAccessWithHttpInfo(accessId); return resp.getData(); } /** * Get access * Retrieve the access with **accessId**. The retrieved object does not contain sensitive information such as the PIN. * @param accessId The **id** for the access to retrieve. (required) * @return ApiResponse<Access> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<Access> getAccessWithHttpInfo(Long accessId) throws ApiException { com.squareup.okhttp.Call call = getAccessCall(accessId, null, null); Type localVarReturnType = new TypeToken<Access>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Get access (asynchronously) * Retrieve the access with **accessId**. The retrieved object does not contain sensitive information such as the PIN. * @param accessId The **id** for the access to retrieve. (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 getAccessAsync(Long accessId, final ApiCallback<Access> 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 = getAccessCall(accessId, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<Access>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for getAccesses */ private com.squareup.okhttp.Call getAccessesCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/v2/accesses".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 = { }; 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[] { "apiKey" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * List accesses * Returns all registered accesses for the authenticated user. Confidential information like the PIN will not be returned. * @return List<Access> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public List<Access> getAccesses() throws ApiException { ApiResponse<List<Access>> resp = getAccessesWithHttpInfo(); return resp.getData(); } /** * List accesses * Returns all registered accesses for the authenticated user. Confidential information like the PIN will not be returned. * @return ApiResponse<List<Access>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<List<Access>> getAccessesWithHttpInfo() throws ApiException { com.squareup.okhttp.Call call = getAccessesCall(null, null); Type localVarReturnType = new TypeToken<List<Access>>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * List accesses (asynchronously) * Returns all registered accesses for the authenticated user. Confidential information like the PIN will not be returned. * @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 getAccessesAsync(final ApiCallback<List<Access>> 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 = getAccessesCall(progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<List<Access>>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for postAccess */ private com.squareup.okhttp.Call postAccessCall(Access accessDto, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = accessDto; // verify the required parameter 'accessDto' is set if (accessDto == null) { throw new ApiException("Missing the required parameter 'accessDto' when calling postAccess(Async)"); } // create path and map variables String localVarPath = "/v2/accesses".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[] { "apiKey" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Create a new access * Create a new access and setup all associated accounts and transactions. This will also trigger the creation of monthly transaction summaries, the analysis of all accounts for recurring transactions, and the calculation of the balance forecast. If the credentials were invalid, the validation state is set accordingly. It is possible to have multiple accesses for one user. * @param accessDto A valid BankAccess object containing the required **accessFields** as indicated by the provider object and the **providerId**. (required) * @return Access * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public Access postAccess(Access accessDto) throws ApiException { ApiResponse<Access> resp = postAccessWithHttpInfo(accessDto); return resp.getData(); } /** * Create a new access * Create a new access and setup all associated accounts and transactions. This will also trigger the creation of monthly transaction summaries, the analysis of all accounts for recurring transactions, and the calculation of the balance forecast. If the credentials were invalid, the validation state is set accordingly. It is possible to have multiple accesses for one user. * @param accessDto A valid BankAccess object containing the required **accessFields** as indicated by the provider object and the **providerId**. (required) * @return ApiResponse<Access> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<Access> postAccessWithHttpInfo(Access accessDto) throws ApiException { com.squareup.okhttp.Call call = postAccessCall(accessDto, null, null); Type localVarReturnType = new TypeToken<Access>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Create a new access (asynchronously) * Create a new access and setup all associated accounts and transactions. This will also trigger the creation of monthly transaction summaries, the analysis of all accounts for recurring transactions, and the calculation of the balance forecast. If the credentials were invalid, the validation state is set accordingly. It is possible to have multiple accesses for one user. * @param accessDto A valid BankAccess object containing the required **accessFields** as indicated by the provider object and the **providerId**. (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 postAccessAsync(Access accessDto, final ApiCallback<Access> 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 = postAccessCall(accessDto, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<Access>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } /* Build call for putAccess */ private com.squareup.okhttp.Call putAccessCall(Long accessId, Access accessDto, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = accessDto; // verify the required parameter 'accessId' is set if (accessId == null) { throw new ApiException("Missing the required parameter 'accessId' when calling putAccess(Async)"); } // verify the required parameter 'accessDto' is set if (accessDto == null) { throw new ApiException("Missing the required parameter 'accessDto' when calling putAccess(Async)"); } // create path and map variables String localVarPath = "/v2/accesses/{accessId}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "accessId" + "\\}", apiClient.escapeString(accessId.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[] { "apiKey" }; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Update access * Update the access credentials in **accessFields**. If the access does not exist, the **accessId** does not match the **id** in **accessDto** or the **providerId** is not the same, the status code 404 is returned. If another access with the same login data already exists, the status code 409 is returned. The updated access is validated by setting up an account. The status code 200 does not imply that the credentials are correct. To check this the client should obtain access. * @param accessId The **id** for the access to update. (required) * @param accessDto The Access object that contains the changed credentials in **accessFields**. Other fields cannot be edited. (required) * @return Access * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public Access putAccess(Long accessId, Access accessDto) throws ApiException { ApiResponse<Access> resp = putAccessWithHttpInfo(accessId, accessDto); return resp.getData(); } /** * Update access * Update the access credentials in **accessFields**. If the access does not exist, the **accessId** does not match the **id** in **accessDto** or the **providerId** is not the same, the status code 404 is returned. If another access with the same login data already exists, the status code 409 is returned. The updated access is validated by setting up an account. The status code 200 does not imply that the credentials are correct. To check this the client should obtain access. * @param accessId The **id** for the access to update. (required) * @param accessDto The Access object that contains the changed credentials in **accessFields**. Other fields cannot be edited. (required) * @return ApiResponse<Access> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<Access> putAccessWithHttpInfo(Long accessId, Access accessDto) throws ApiException { com.squareup.okhttp.Call call = putAccessCall(accessId, accessDto, null, null); Type localVarReturnType = new TypeToken<Access>() { }.getType(); return apiClient.execute(call, localVarReturnType); } /** * Update access (asynchronously) * Update the access credentials in **accessFields**. If the access does not exist, the **accessId** does not match the **id** in **accessDto** or the **providerId** is not the same, the status code 404 is returned. If another access with the same login data already exists, the status code 409 is returned. The updated access is validated by setting up an account. The status code 200 does not imply that the credentials are correct. To check this the client should obtain access. * @param accessId The **id** for the access to update. (required) * @param accessDto The Access object that contains the changed credentials in **accessFields**. Other fields cannot be edited. (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 putAccessAsync(Long accessId, Access accessDto, final ApiCallback<Access> 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 = putAccessCall(accessId, accessDto, progressListener, progressRequestListener); Type localVarReturnType = new TypeToken<Access>() { }.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } }