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

com.foresee.api.sdk.CxMeasuresClient Maven / Gradle / Ivy

There is a newer version: 1.2.4-M3
Show newest version
package com.foresee.api.sdk;

import com.amazonaws.mobileconnectors.apigateway.ApiClientException;
import com.foresee.api.sdk.clients.BaseApiClient;
import com.foresee.api.sdk.common.Environment;
import com.foresee.api.sdk.exceptions.ApiAuthenticationException;
import com.foresee.api.sdk.exceptions.ApiException;
import com.foresee.api.sdk.exceptions.ApiExceptionsBuilder;
import com.foresee.api.sdk.exceptions.InvalidTokenException;
import com.foresee.api.sdk.model.MeasureData;
import com.foresee.api.sdk.model.MeasureDefinition;
import com.foresee.api.sdk.model.MeasuresCollection;
import lombok.Getter;

@Getter
public final class CxMeasuresClient extends BaseApiClient {
    /* Flag to indicate if you want the request to enable debug level logging*/
    @Deprecated
    private boolean debugEnabled;

    /**
     *
     * @param environment
     * @param @Deprecated debugEnabled
     */
    public CxMeasuresClient(Environment environment, @Deprecated boolean debugEnabled) {
        super(environment);
        this.debugEnabled = debugEnabled;
    }


    /**
     * Get the list of Measures
     * @return
     */
    public MeasuresCollection getMeasures(String accessToken) throws ApiAuthenticationException, InvalidTokenException,
            ApiException {
        try {
            MeasuresCollection measuresCollection = apiClient().measuresGet(CONTENT_TYPE_JSON, CONTENT_TYPE_JSON, Boolean.toString(debugEnabled),
                    getAuthorizationHeader(accessToken));
            return  measuresCollection;
        } catch (ApiClientException ae) {
            ApiException apiException = ApiExceptionsBuilder.handleApiClientExceptions(ae);
            if (apiException instanceof InvalidTokenException) {
                throw (InvalidTokenException) apiException;
            } else {
                throw apiException;
            }

        }
    }

    /**
     * Get the Measurement Definition
     * @return
     */
    public MeasureDefinition getMeasurementDefinition(String accessToken, Long measurementKey, boolean excludeQuestions,
                                                      boolean excludeAnswers) throws ApiAuthenticationException, ApiException {
        try {
            MeasureDefinition measureDefinition = apiClient().measuresMeasurementKeyDefinitionGet(Long.toString(measurementKey),
                    CONTENT_TYPE_JSON, Boolean.toString(excludeQuestions),
                    getAuthorizationHeader(accessToken),
                    CONTENT_TYPE_JSON, Boolean.toString(debugEnabled),Boolean.toString(excludeAnswers));
            return measureDefinition;
        } catch (ApiClientException ae) {
            ApiException apiException = ApiExceptionsBuilder.handleApiClientExceptions(ae);
            if (apiException instanceof InvalidTokenException) {
                throw (InvalidTokenException) apiException;
            } else {
                throw apiException;
            }
        }
    }

    /**
     * Get the Measurement Data
     * @return
     */
    public MeasureData getMeasurementData(String accessToken, Long measurementKey, boolean excludeLatentScores,
        boolean excludeResponseDetails,boolean excludeMQ, boolean excludeCQ, boolean excludePassedParams,
                                          String from, String to, int limit, int offset) throws ApiAuthenticationException, ApiException {
        try {
            MeasureData measureData = apiClient().measuresMeasurementKeyDataGet(Long.toString(measurementKey),
                    Boolean.toString(excludeLatentScores), Boolean.toString(excludeResponseDetails),
                    CONTENT_TYPE_JSON, "false", Boolean.toString(excludeMQ), from, to, "false",
                    Boolean.toString(excludeCQ), CONTENT_TYPE_JSON, Integer.toString(limit), Integer.toString(offset),
                    getAuthorizationHeader(accessToken),
                    Boolean.toString(excludePassedParams), Boolean.toString(debugEnabled));
            return measureData;
        } catch (ApiClientException ae) {
            ApiException apiException = ApiExceptionsBuilder.handleApiClientExceptions(ae);
            if (apiException instanceof InvalidTokenException) {
                throw (InvalidTokenException) apiException;
            } else {
                throw apiException;
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy