All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.swagger.client.api.ChatHistoryApi 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 java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ChatHistoryApi {
    private ApiClient apiClient;

    public ChatHistoryApi() {
        this(Configuration.getDefaultApiClient());
    }

    public ChatHistoryApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /* Build call for orgNameAppNameChatmessagesGet */
    private com.squareup.okhttp.Call orgNameAppNameChatmessagesGetCall(String orgName, String appName, String authorization, String ql, String limit, String cursor, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/{org_name}/{app_name}/chatmessages".replaceAll("\\{format\\}","json")
        .replaceAll("\\{" + "org_name" + "\\}", apiClient.escapeString(orgName.toString()))
        .replaceAll("\\{" + "app_name" + "\\}", apiClient.escapeString(appName.toString()));

        List localVarQueryParams = new ArrayList();
        if (ql != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "ql", ql));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "limit", limit));
        if (cursor != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "cursor", cursor));

        Map localVarHeaderParams = new HashMap();
        if (authorization != null)
        localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));

        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, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call orgNameAppNameChatmessagesGetValidateBeforeCall(String orgName, String appName, String authorization, String ql, String limit, String cursor, 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 orgNameAppNameChatmessagesGet(Async)");
        }
        
        // verify the required parameter 'appName' is set
        if (appName == null) {
            throw new ApiException("Missing the required parameter 'appName' when calling orgNameAppNameChatmessagesGet(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling orgNameAppNameChatmessagesGet(Async)");
        }
        
        
        com.squareup.okhttp.Call call = orgNameAppNameChatmessagesGetCall(orgName, appName, authorization, ql, limit, cursor, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Get Message History
     * 
     * @param orgName Organization ID (required)
     * @param appName Application name (required)
     * @param authorization Bearer ${token} (required)
     * @param ql Get messages based on starting  timestamp. Could also alter the comparison to get later, equal, or earlier messages. ex. ql=select+*+where+timestamp>1403164734226 or =<[timestamp] (optional, default to select+*+where+timestamp>1403164734226)
     * @param limit total number of messages per page by pagination at a time (optional, default to 3)
     * @param cursor Get messages by pagination. Obtained \"cursor\" from the previous GET messages call response. (optional, default to )
     * @return String
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public String orgNameAppNameChatmessagesGet(String orgName, String appName, String authorization, String ql, String limit, String cursor) throws ApiException {
        ApiResponse resp = orgNameAppNameChatmessagesGetWithHttpInfo(orgName, appName, authorization, ql, limit, cursor);
        return resp.getData();
    }

    /**
     * Get Message History
     * 
     * @param orgName Organization ID (required)
     * @param appName Application name (required)
     * @param authorization Bearer ${token} (required)
     * @param ql Get messages based on starting  timestamp. Could also alter the comparison to get later, equal, or earlier messages. ex. ql=select+*+where+timestamp>1403164734226 or =<[timestamp] (optional, default to select+*+where+timestamp>1403164734226)
     * @param limit total number of messages per page by pagination at a time (optional, default to 3)
     * @param cursor Get messages by pagination. Obtained \"cursor\" from the previous GET messages call response. (optional, default to )
     * @return ApiResponse<String>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse orgNameAppNameChatmessagesGetWithHttpInfo(String orgName, String appName, String authorization, String ql, String limit, String cursor) throws ApiException {
        com.squareup.okhttp.Call call = orgNameAppNameChatmessagesGetValidateBeforeCall(orgName, appName, authorization, ql, limit, cursor, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get Message History (asynchronously)
     * 
     * @param orgName Organization ID (required)
     * @param appName Application name (required)
     * @param authorization Bearer ${token} (required)
     * @param ql Get messages based on starting  timestamp. Could also alter the comparison to get later, equal, or earlier messages. ex. ql=select+*+where+timestamp>1403164734226 or =<[timestamp] (optional, default to select+*+where+timestamp>1403164734226)
     * @param limit total number of messages per page by pagination at a time (optional, default to 3)
     * @param cursor Get messages by pagination. Obtained \"cursor\" from the previous GET messages call response. (optional, default to )
     * @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 orgNameAppNameChatmessagesGetAsync(String orgName, String appName, String authorization, String ql, String limit, String cursor, 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 = orgNameAppNameChatmessagesGetValidateBeforeCall(orgName, appName, authorization, ql, limit, cursor, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /* Build call for orgNameAppNameChatmessagesTimeGet */
    private com.squareup.okhttp.Call orgNameAppNameChatmessagesTimeGetCall(String orgName, String appName, String authorization, String time, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/{org_name}/{app_name}/chatmessages/{time}".replaceAll("\\{format\\}","json")
        .replaceAll("\\{" + "org_name" + "\\}", apiClient.escapeString(orgName.toString()))
        .replaceAll("\\{" + "app_name" + "\\}", apiClient.escapeString(appName.toString()))
        .replaceAll("\\{" + "time" + "\\}", apiClient.escapeString(time.toString()));

        List localVarQueryParams = new ArrayList();

        Map localVarHeaderParams = new HashMap();
        if (authorization != null)
        localVarHeaderParams.put("Authorization", apiClient.parameterToString(authorization));

        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, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call orgNameAppNameChatmessagesTimeGetValidateBeforeCall(String orgName, String appName, String authorization, String time, 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 orgNameAppNameChatmessagesTimeGet(Async)");
        }
        
        // verify the required parameter 'appName' is set
        if (appName == null) {
            throw new ApiException("Missing the required parameter 'appName' when calling orgNameAppNameChatmessagesTimeGet(Async)");
        }
        
        // verify the required parameter 'authorization' is set
        if (authorization == null) {
            throw new ApiException("Missing the required parameter 'authorization' when calling orgNameAppNameChatmessagesTimeGet(Async)");
        }
        
        // verify the required parameter 'time' is set
        if (time == null) {
            throw new ApiException("Missing the required parameter 'time' when calling orgNameAppNameChatmessagesTimeGet(Async)");
        }
        
        
        com.squareup.okhttp.Call call = orgNameAppNameChatmessagesTimeGetCall(orgName, appName, authorization, time, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Get Message History by Hour
     * 
     * @param orgName Organization ID (required)
     * @param appName Application name (required)
     * @param authorization Bearer ${token} (required)
     * @param time Format as (YYYYMMDDHH) (required)
     * @return String
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public String orgNameAppNameChatmessagesTimeGet(String orgName, String appName, String authorization, String time) throws ApiException {
        ApiResponse resp = orgNameAppNameChatmessagesTimeGetWithHttpInfo(orgName, appName, authorization, time);
        return resp.getData();
    }

    /**
     * Get Message History by Hour
     * 
     * @param orgName Organization ID (required)
     * @param appName Application name (required)
     * @param authorization Bearer ${token} (required)
     * @param time Format as (YYYYMMDDHH) (required)
     * @return ApiResponse<String>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse orgNameAppNameChatmessagesTimeGetWithHttpInfo(String orgName, String appName, String authorization, String time) throws ApiException {
        com.squareup.okhttp.Call call = orgNameAppNameChatmessagesTimeGetValidateBeforeCall(orgName, appName, authorization, time, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get Message History by Hour (asynchronously)
     * 
     * @param orgName Organization ID (required)
     * @param appName Application name (required)
     * @param authorization Bearer ${token} (required)
     * @param time Format as (YYYYMMDDHH) (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 orgNameAppNameChatmessagesTimeGetAsync(String orgName, String appName, String authorization, String time, 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 = orgNameAppNameChatmessagesTimeGetValidateBeforeCall(orgName, appName, authorization, time, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy