io.swagger.client.api.AuthenticationApi Maven / Gradle / Ivy
The newest version!
/*
* Easemob REST APIs
* Easemob Server REST API Swagger is designated to provide better documentation and thorough interfaces for testing. For more details about server implementation, request rate limitation, etc, please visit [Easemob Server Integration](http://docs.easemob.com/im/100serverintegration/10intro). **Note:** `org_ID` is the unique ID of the organization created when you first registered [Easemob console](https://console.easemob.com/). `app_name` is the unique app ID created when you new application in [Easemob console](https://console.easemob.com/). `Authorization token` is required for most API requests as part of requesting header in the format `Bearer ${token}`. You can obtain the token via [/{org_name}/{app_name}/token](https://docs.hyphenate.io/docs/server-overview#section-request-authentication-token).
*
* OpenAPI spec version: 1.0.2
*
*
* 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.
*/
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.Token;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AuthenticationApi {
private ApiClient apiClient;
public AuthenticationApi() {
this(Configuration.getDefaultApiClient());
}
public AuthenticationApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/* Build call for orgNameAppNameTokenPost */
private com.squareup.okhttp.Call orgNameAppNameTokenPostCall(String orgName, String appName, Token body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = body;
// create path and map variables
String localVarPath = "/{org_name}/{app_name}/token".replaceAll("\\{format\\}","json")
.replaceAll("\\{" + "org_name" + "\\}", apiClient.escapeString(orgName.toString()))
.replaceAll("\\{" + "app_name" + "\\}", apiClient.escapeString(appName.toString()));
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
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);
}
@SuppressWarnings("rawtypes")
private com.squareup.okhttp.Call orgNameAppNameTokenPostValidateBeforeCall(String orgName, String appName, Token body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'orgName' is set
if (orgName == null) {
throw new ApiException("Missing the required parameter 'orgName' when calling orgNameAppNameTokenPost(Async)");
}
// verify the required parameter 'appName' is set
if (appName == null) {
throw new ApiException("Missing the required parameter 'appName' when calling orgNameAppNameTokenPost(Async)");
}
// verify the required parameter 'body' is set
if (body == null) {
throw new ApiException("Missing the required parameter 'body' when calling orgNameAppNameTokenPost(Async)");
}
com.squareup.okhttp.Call call = orgNameAppNameTokenPostCall(orgName, appName, body, progressListener, progressRequestListener);
return call;
}
/**
* Request an Authentication Token
* All of the Hyphenate API endpoints requires authentication token for session, unless specified otherwise.
* @param orgName Organization ID (required)
* @param appName Application name (required)
* @param body client_id and client_secret can be found in the application details page of the Hyphenate console (required)
* @return String
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public String orgNameAppNameTokenPost(String orgName, String appName, Token body) throws ApiException {
ApiResponse resp = orgNameAppNameTokenPostWithHttpInfo(orgName, appName, body);
return resp.getData();
}
/**
* Request an Authentication Token
* All of the Hyphenate API endpoints requires authentication token for session, unless specified otherwise.
* @param orgName Organization ID (required)
* @param appName Application name (required)
* @param body client_id and client_secret can be found in the application details page of the Hyphenate console (required)
* @return ApiResponse<String>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse orgNameAppNameTokenPostWithHttpInfo(String orgName, String appName, Token body) throws ApiException {
com.squareup.okhttp.Call call = orgNameAppNameTokenPostValidateBeforeCall(orgName, appName, body, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Request an Authentication Token (asynchronously)
* All of the Hyphenate API endpoints requires authentication token for session, unless specified otherwise.
* @param orgName Organization ID (required)
* @param appName Application name (required)
* @param body client_id and client_secret can be found in the application details page of the Hyphenate console (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 orgNameAppNameTokenPostAsync(String orgName, String appName, Token body, final ApiCallback 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 = orgNameAppNameTokenPostValidateBeforeCall(orgName, appName, body, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy