|
| 1 | +package Api; |
| 2 | + |
| 3 | +import Invokers.ApiCallback; |
| 4 | +import Invokers.ApiClient; |
| 5 | +import Invokers.ApiException; |
| 6 | +import Invokers.ApiResponse; |
| 7 | +import Invokers.Configuration; |
| 8 | +import Invokers.Pair; |
| 9 | +import Invokers.ProgressRequestBody; |
| 10 | +import Invokers.ProgressResponseBody; |
| 11 | + |
| 12 | +import Model.*; |
| 13 | +import com.google.gson.reflect.TypeToken; |
| 14 | + |
| 15 | +import java.io.IOException; |
| 16 | +import java.io.InputStream; |
| 17 | + |
| 18 | + |
| 19 | +import java.lang.reflect.Type; |
| 20 | +import java.util.ArrayList; |
| 21 | +import java.util.HashMap; |
| 22 | +import java.util.List; |
| 23 | +import java.util.Map; |
| 24 | + |
| 25 | +public class OAuthApi { |
| 26 | + private ApiClient apiClient; |
| 27 | + |
| 28 | + public OAuthApi() { |
| 29 | + this(Configuration.getDefaultApiClient()); |
| 30 | + } |
| 31 | + |
| 32 | + public OAuthApi(ApiClient apiClient) { |
| 33 | + this.apiClient = apiClient; |
| 34 | + } |
| 35 | + |
| 36 | + public ApiClient getApiClient() { |
| 37 | + return apiClient; |
| 38 | + } |
| 39 | + |
| 40 | + public void setApiClient(ApiClient apiClient) { |
| 41 | + this.apiClient = apiClient; |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Build call for postAccessTokenFromAuthCode |
| 46 | + * @param createAccessTokenRequest (required) |
| 47 | + * @param progressListener Progress listener |
| 48 | + * @param progressRequestListener Progress request listener |
| 49 | + * @return Call to execute |
| 50 | + * @throws ApiException If fail to serialize the request body object |
| 51 | + */ |
| 52 | + public okhttp3.Call postAccessTokenFromAuthCodeCall(CreateAccessTokenRequest createAccessTokenRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 53 | + Object localVarPostBody = createAccessTokenRequest; |
| 54 | + |
| 55 | + // create path and map variables |
| 56 | + String localVarPath = "/oauth2/v3/token"; |
| 57 | + |
| 58 | + List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 59 | + |
| 60 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 61 | + |
| 62 | + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 63 | + |
| 64 | + final String[] localVarAccepts = { |
| 65 | + "*/*" |
| 66 | + }; |
| 67 | + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); |
| 68 | + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); |
| 69 | + |
| 70 | + final String[] localVarContentTypes = { |
| 71 | + "application/x-www-form-urlencoded" |
| 72 | + }; |
| 73 | + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); |
| 74 | + localVarHeaderParams.put("Content-Type", localVarContentType); |
| 75 | + |
| 76 | + if(progressListener != null) { |
| 77 | + apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { |
| 78 | + @Override |
| 79 | + public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { |
| 80 | + okhttp3.Response originalResponse = chain.proceed(chain.request()); |
| 81 | + return originalResponse.newBuilder() |
| 82 | + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) |
| 83 | + .build(); |
| 84 | + } |
| 85 | + }); |
| 86 | + } |
| 87 | + |
| 88 | + String[] localVarAuthNames = new String[] { }; |
| 89 | + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); |
| 90 | + } |
| 91 | + |
| 92 | + @SuppressWarnings("rawtypes") |
| 93 | + private okhttp3.Call postAccessTokenFromAuthCodeValidateBeforeCall(CreateAccessTokenRequest createAccessTokenRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 94 | + |
| 95 | + // verify the required parameter 'CreateAccessTokenRequest' is set |
| 96 | + if (createAccessTokenRequest == null) { |
| 97 | + throw new ApiException("Missing the required parameter 'createAccessTokenRequest' when calling postAccessTokenFromAuthCode(Async)"); |
| 98 | + } |
| 99 | + |
| 100 | + |
| 101 | + okhttp3.Call call = postAccessTokenFromAuthCodeCall(createAccessTokenRequest, progressListener, progressRequestListener); |
| 102 | + return call; |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * Post Access Token from Auth Code |
| 107 | + * @param createAccessTokenRequest (required) |
| 108 | + * @return AccessTokenResponse |
| 109 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 110 | + */ |
| 111 | + public AccessTokenResponse postAccessTokenFromAuthCode(CreateAccessTokenRequest createAccessTokenRequest) throws ApiException { |
| 112 | + this.apiClient.setComputationStartTime(System.nanoTime()); |
| 113 | + ApiResponse<AccessTokenResponse> resp = postAccessTokenFromAuthCodeWithHttpInfo(createAccessTokenRequest); |
| 114 | + return resp.getData(); |
| 115 | + } |
| 116 | + |
| 117 | + |
| 118 | + /** |
| 119 | + * Post Access Token from Auth Code |
| 120 | + * @param createAccessTokenRequest (required) |
| 121 | + * @return ApiResponse<AccessTokenResponse> |
| 122 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 123 | + */ |
| 124 | + |
| 125 | + public ApiResponse<AccessTokenResponse> postAccessTokenFromAuthCodeWithHttpInfo(CreateAccessTokenRequest createAccessTokenRequest) throws ApiException { |
| 126 | + okhttp3.Call call = postAccessTokenFromAuthCodeValidateBeforeCall(createAccessTokenRequest, null, null); |
| 127 | + Type localVarReturnType = new TypeToken<AccessTokenResponse>(){}.getType(); |
| 128 | + return apiClient.execute(call, localVarReturnType); |
| 129 | + } |
| 130 | + |
| 131 | + /** |
| 132 | + * Post Access Token from Auth Code (asynchronously) |
| 133 | + * @param createAccessTokenRequest (required) |
| 134 | + * @param callback The callback to be executed when the API call finishes |
| 135 | + * @return The request call |
| 136 | + * @throws ApiException If fail to process the API call, e.g. serializing the request body object |
| 137 | + */ |
| 138 | + |
| 139 | + public okhttp3.Call postAccessTokenFromAuthCodeAsync(CreateAccessTokenRequest createAccessTokenRequest, final ApiCallback<AccessTokenResponse> callback) throws ApiException { |
| 140 | + |
| 141 | + this.apiClient.setComputationStartTime(System.nanoTime()); |
| 142 | + ProgressResponseBody.ProgressListener progressListener = null; |
| 143 | + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; |
| 144 | + |
| 145 | + if (callback != null) { |
| 146 | + progressListener = new ProgressResponseBody.ProgressListener() { |
| 147 | + @Override |
| 148 | + public void update(long bytesRead, long contentLength, boolean done) { |
| 149 | + callback.onDownloadProgress(bytesRead, contentLength, done); |
| 150 | + } |
| 151 | + }; |
| 152 | + |
| 153 | + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { |
| 154 | + @Override |
| 155 | + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { |
| 156 | + callback.onUploadProgress(bytesWritten, contentLength, done); |
| 157 | + } |
| 158 | + }; |
| 159 | + } |
| 160 | + |
| 161 | + okhttp3.Call call = postAccessTokenFromAuthCodeValidateBeforeCall(createAccessTokenRequest, progressListener, progressRequestListener); |
| 162 | + Type localVarReturnType = new TypeToken<AccessTokenResponse>(){}.getType(); |
| 163 | + apiClient.executeAsync(call, localVarReturnType, callback); |
| 164 | + return call; |
| 165 | + } |
| 166 | + |
| 167 | + |
| 168 | + /** |
| 169 | + * Build call for postAccessTokenFromRefreshToken |
| 170 | + * @param createAccessTokenRequest (required) |
| 171 | + * @param progressListener Progress listener |
| 172 | + * @param progressRequestListener Progress request listener |
| 173 | + * @return Call to execute |
| 174 | + * @throws ApiException If fail to serialize the request body object |
| 175 | + */ |
| 176 | + public okhttp3.Call postAccessTokenFromRefreshTokenCall(CreateAccessTokenRequest createAccessTokenRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 177 | + Object localVarPostBody = createAccessTokenRequest; |
| 178 | + |
| 179 | + // create path and map variables |
| 180 | + String localVarPath = "/oauth2/v3/token"; |
| 181 | + |
| 182 | + List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 183 | + |
| 184 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 185 | + |
| 186 | + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 187 | + |
| 188 | + final String[] localVarAccepts = { |
| 189 | + "*/*" |
| 190 | + }; |
| 191 | + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); |
| 192 | + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); |
| 193 | + |
| 194 | + final String[] localVarContentTypes = { |
| 195 | + "application/x-www-form-urlencoded" |
| 196 | + }; |
| 197 | + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); |
| 198 | + localVarHeaderParams.put("Content-Type", localVarContentType); |
| 199 | + |
| 200 | + if(progressListener != null) { |
| 201 | + apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() { |
| 202 | + @Override |
| 203 | + public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException { |
| 204 | + okhttp3.Response originalResponse = chain.proceed(chain.request()); |
| 205 | + return originalResponse.newBuilder() |
| 206 | + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) |
| 207 | + .build(); |
| 208 | + } |
| 209 | + }); |
| 210 | + } |
| 211 | + |
| 212 | + String[] localVarAuthNames = new String[] { }; |
| 213 | + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); |
| 214 | + } |
| 215 | + |
| 216 | + @SuppressWarnings("rawtypes") |
| 217 | + private okhttp3.Call postAccessTokenFromRefreshTokenValidateBeforeCall(CreateAccessTokenRequest createAccessTokenRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 218 | + |
| 219 | + // verify the required parameter 'CreateAccessTokenRequest' is set |
| 220 | + if (createAccessTokenRequest == null) { |
| 221 | + throw new ApiException("Missing the required parameter 'createAccessTokenRequest' when calling postAccessTokenFromRefreshToken(Async)"); |
| 222 | + } |
| 223 | + |
| 224 | + |
| 225 | + okhttp3.Call call = postAccessTokenFromRefreshTokenCall(createAccessTokenRequest, progressListener, progressRequestListener); |
| 226 | + return call; |
| 227 | + } |
| 228 | + |
| 229 | + /** |
| 230 | + * Post Access Token from Refresh Token |
| 231 | + * @param createAccessTokenRequest (required) |
| 232 | + * @return AccessTokenResponse |
| 233 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 234 | + */ |
| 235 | + public AccessTokenResponse postAccessTokenFromRefreshToken(CreateAccessTokenRequest createAccessTokenRequest) throws ApiException { |
| 236 | + this.apiClient.setComputationStartTime(System.nanoTime()); |
| 237 | + ApiResponse<AccessTokenResponse> resp = postAccessTokenFromRefreshTokenWithHttpInfo(createAccessTokenRequest); |
| 238 | + return resp.getData(); |
| 239 | + } |
| 240 | + |
| 241 | + |
| 242 | + /** |
| 243 | + * Post Access Token from Refresh Token |
| 244 | + * @param createAccessTokenRequest (required) |
| 245 | + * @return ApiResponse<AccessTokenResponse> |
| 246 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 247 | + */ |
| 248 | + |
| 249 | + public ApiResponse<AccessTokenResponse> postAccessTokenFromRefreshTokenWithHttpInfo(CreateAccessTokenRequest createAccessTokenRequest) throws ApiException { |
| 250 | + okhttp3.Call call = postAccessTokenFromRefreshTokenValidateBeforeCall(createAccessTokenRequest, null, null); |
| 251 | + Type localVarReturnType = new TypeToken<AccessTokenResponse>(){}.getType(); |
| 252 | + return apiClient.execute(call, localVarReturnType); |
| 253 | + } |
| 254 | + |
| 255 | + /** |
| 256 | + * Post Access Token from Refresh Token (asynchronously) |
| 257 | + * @param createAccessTokenRequest (required) |
| 258 | + * @param callback The callback to be executed when the API call finishes |
| 259 | + * @return The request call |
| 260 | + * @throws ApiException If fail to process the API call, e.g. serializing the request body object |
| 261 | + */ |
| 262 | + |
| 263 | + public okhttp3.Call postAccessTokenFromRefreshTokenAsync(CreateAccessTokenRequest createAccessTokenRequest, final ApiCallback<AccessTokenResponse> callback) throws ApiException { |
| 264 | + |
| 265 | + this.apiClient.setComputationStartTime(System.nanoTime()); |
| 266 | + ProgressResponseBody.ProgressListener progressListener = null; |
| 267 | + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; |
| 268 | + |
| 269 | + if (callback != null) { |
| 270 | + progressListener = new ProgressResponseBody.ProgressListener() { |
| 271 | + @Override |
| 272 | + public void update(long bytesRead, long contentLength, boolean done) { |
| 273 | + callback.onDownloadProgress(bytesRead, contentLength, done); |
| 274 | + } |
| 275 | + }; |
| 276 | + |
| 277 | + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { |
| 278 | + @Override |
| 279 | + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { |
| 280 | + callback.onUploadProgress(bytesWritten, contentLength, done); |
| 281 | + } |
| 282 | + }; |
| 283 | + } |
| 284 | + |
| 285 | + okhttp3.Call call = postAccessTokenFromRefreshTokenValidateBeforeCall(createAccessTokenRequest, progressListener, progressRequestListener); |
| 286 | + Type localVarReturnType = new TypeToken<AccessTokenResponse>(){}.getType(); |
| 287 | + apiClient.executeAsync(call, localVarReturnType, callback); |
| 288 | + return call; |
| 289 | + } |
| 290 | +} |
0 commit comments