|
| 1 | +{{>licenseInfo}} |
| 2 | +package {{invokerPackage}}; |
| 3 | + |
| 4 | +import com.fasterxml.jackson.core.type.TypeReference; |
| 5 | + |
| 6 | +import java.util.Collections; |
| 7 | +import java.util.Map; |
| 8 | + |
| 9 | +{{>generatedAnnotation}} |
| 10 | +public abstract class BaseApi { |
| 11 | +
|
| 12 | + protected ApiClient apiClient; |
| 13 | +
|
| 14 | + public BaseApi() { |
| 15 | + this(Configuration.getDefaultApiClient()); |
| 16 | + } |
| 17 | + |
| 18 | + public BaseApi(ApiClient apiClient) { |
| 19 | + this.apiClient = apiClient; |
| 20 | + } |
| 21 | + |
| 22 | + public ApiClient getApiClient() { |
| 23 | + return apiClient; |
| 24 | + } |
| 25 | + |
| 26 | + public void setApiClient(ApiClient apiClient) { |
| 27 | + this.apiClient = apiClient; |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. |
| 32 | + * @param url The URL for the request, either full URL or only the path. |
| 33 | + * @param method The HTTP method for the request. |
| 34 | + * @throws ApiException if fails to make API call. |
| 35 | + */ |
| 36 | + public void invokeAPI(String url, String method) throws ApiException { |
| 37 | + invokeAPI(url, method, null, null, Collections.emptyMap()); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. |
| 42 | + * @param url The URL for the request, either full URL or only the path. |
| 43 | + * @param method The HTTP method for the request. |
| 44 | + * @param additionalHeaders Additional headers for the request. |
| 45 | + * @throws ApiException if fails to make API call. |
| 46 | + */ |
| 47 | + public void invokeAPI(String url, String method, Map<String, String> additionalHeaders) throws ApiException { |
| 48 | + invokeAPI(url, method, null, null, additionalHeaders); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. |
| 53 | + * @param url The URL for the request, either full URL or only the path. |
| 54 | + * @param method The HTTP method for the request. |
| 55 | + * @param request The request object. |
| 56 | + * @throws ApiException if fails to make API call. |
| 57 | + */ |
| 58 | + public void invokeAPI(String url, String method, Object request) throws ApiException { |
| 59 | + invokeAPI(url, method, request, null, Collections.emptyMap()); |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. |
| 64 | + * @param url The URL for the request, either full URL or only the path. |
| 65 | + * @param method The HTTP method for the request. |
| 66 | + * @param request The request object. |
| 67 | + * @param additionalHeaders Additional headers for the request. |
| 68 | + * @throws ApiException if fails to make API call. |
| 69 | + */ |
| 70 | + public void invokeAPI(String url, String method, Object request, Map<String, String> additionalHeaders) throws ApiException { |
| 71 | + invokeAPI(url, method, request, null, additionalHeaders); |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. |
| 76 | + * @param url The URL for the request, either full URL or only the path. |
| 77 | + * @param method The HTTP method for the request. |
| 78 | + * @param returnType The return type. |
| 79 | + * @return The API response in the specified type. |
| 80 | + * @throws ApiException if fails to make API call. |
| 81 | + */ |
| 82 | + public <T> T invokeAPI(String url, String method, TypeReference<T> returnType) throws ApiException { |
| 83 | + return invokeAPI(url, method, null, returnType, Collections.emptyMap()); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. |
| 88 | + * @param url The URL for the request, either full URL or only the path. |
| 89 | + * @param method The HTTP method for the request. |
| 90 | + * @param request The request object. |
| 91 | + * @param returnType The return type. |
| 92 | + * @return The API response in the specified type. |
| 93 | + * @throws ApiException if fails to make API call. |
| 94 | + */ |
| 95 | + public <T> T invokeAPI(String url, String method, Object request, TypeReference<T> returnType) throws ApiException { |
| 96 | + return invokeAPI(url, method, request, returnType, Collections.emptyMap()); |
| 97 | + } |
| 98 | + |
| 99 | + /** |
| 100 | + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. |
| 101 | + * @param url The URL for the request, either full URL or only the path. |
| 102 | + * @param method The HTTP method for the request. |
| 103 | + * @param request The request object. |
| 104 | + * @param returnType The return type. |
| 105 | + * @param additionalHeaders Additional headers for the request. |
| 106 | + * @return The API response in the specified type. |
| 107 | + * @throws ApiException if fails to make API call. |
| 108 | + */ |
| 109 | + public abstract <T> T invokeAPI(String url, String method, Object request, TypeReference<T> returnType, Map<String, String> additionalHeaders) throws ApiException; |
| 110 | +} |
0 commit comments