Class APIController

java.lang.Object
com.moesif.api.controllers.BaseController
com.moesif.api.controllers.APIController
All Implemented Interfaces:
IAPIController

public class APIController extends BaseController implements IAPIController
  • Constructor Details

  • Method Details

    • setHttpRequestRetryHandler

      public void setHttpRequestRetryHandler(org.apache.http.client.HttpRequestRetryHandler httpRequestRetryHandler)
    • createEvent

      public Map<String,String> createEvent(EventModel body) throws Throwable
      Add Single API Event Call
      Specified by:
      createEvent in interface IAPIController
      Parameters:
      body - The event to create
      Throws:
      Throwable - on error creating event
    • createEventAsync

      public void createEventAsync(EventModel body, APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Add Single API Event Call
      Specified by:
      createEventAsync in interface IAPIController
      Parameters:
      body - The event to create
      callBack - Called after the HTTP response is received
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error creating event
    • createEventsBatch

      public Map<String,String> createEventsBatch(List<EventModel> body) throws Throwable
      Add multiple API Events in a single batch
      Specified by:
      createEventsBatch in interface IAPIController
      Parameters:
      body - The events to create
      Throws:
      Throwable - on error creating event
    • createEventsBatchAsync

      public void createEventsBatchAsync(List<EventModel> body, APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Description copied from interface: IAPIController
      Add multiple API Events in a single batch
      Specified by:
      createEventsBatchAsync in interface IAPIController
      Parameters:
      body - The events to create
      callBack - Called after the HTTP response is received
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error creating event
    • createEventsBatchAsync

      public void createEventsBatchAsync(List<EventModel> body, APICallBack<HttpResponse> callBack, boolean useGzip) throws com.fasterxml.jackson.core.JsonProcessingException
      Add multiple API Events in a single batch
      Specified by:
      createEventsBatchAsync in interface IAPIController
      Parameters:
      body - The events to create
      callBack - Called after the HTTP response is received
      useGzip - Option to convert body to gzip type
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error creating event
    • createAction

      public void createAction(ActionModel body) throws Throwable
      Send a single custom action to the API.
      Parameters:
      body - The ActionModel object to send.
      Throws:
      Throwable - if an error occurs during the API call.
    • createActionAsync

      public void createActionAsync(ActionModel body, APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Send a single custom action to the API asynchronously.
      Parameters:
      body - The ActionModel object to send.
      callBack - Called after the HTTP response is received.
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during serialization.
    • createActionsBatch

      public void createActionsBatch(List<ActionModel> body) throws Throwable
      Send multiple custom actions to the API in a single batch.
      Parameters:
      body - The list of ActionModel objects to send.
      Throws:
      Throwable - if an error occurs during the API call.
    • createActionsBatchAsync

      public void createActionsBatchAsync(List<ActionModel> body, APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Send multiple custom actions to the API in a single batch asynchronously.
      Parameters:
      body - The list of ActionModel objects to send.
      callBack - Called after the HTTP response is received.
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during serialization.
    • updateUser

      public void updateUser(UserModel body) throws Throwable
      Update a Single User
      Specified by:
      updateUser in interface IAPIController
      Parameters:
      body - The user to update
      Throws:
      Throwable - on error updating user
    • updateUserAsync

      public void updateUserAsync(UserModel body, APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Update a Single User async
      Specified by:
      updateUserAsync in interface IAPIController
      Parameters:
      body - The user to update
      callBack - Called after the HTTP response is received
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error updating user
    • updateUsersBatch

      public void updateUsersBatch(List<UserModel> body) throws Throwable
      Update multiple Users in a single batch
      Specified by:
      updateUsersBatch in interface IAPIController
      Parameters:
      body - The list of users to update
      Throws:
      Throwable - on error updating users
    • updateUsersBatchAsync

      public void updateUsersBatchAsync(List<UserModel> body, APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Update multiple Users in a single batch async
      Specified by:
      updateUsersBatchAsync in interface IAPIController
      Parameters:
      body - The list of users to update
      callBack - Called after the HTTP response is received
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error updating users
    • updateCompany

      public void updateCompany(CompanyModel body) throws Throwable
      Update a Single Company
      Specified by:
      updateCompany in interface IAPIController
      Parameters:
      body - The company to update
      Throws:
      Throwable - on error updating a company
    • updateCompanyAsync

      public void updateCompanyAsync(CompanyModel body, APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Update a Single Company async
      Specified by:
      updateCompanyAsync in interface IAPIController
      Parameters:
      body - The company to update
      callBack - Called after the HTTP response is received
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error updating a company
    • updateCompaniesBatch

      public void updateCompaniesBatch(List<CompanyModel> body) throws Throwable
      Update multiple Companies in a single batch
      Specified by:
      updateCompaniesBatch in interface IAPIController
      Parameters:
      body - The list of companies to update
      Throws:
      Throwable - on error updating companies
    • updateCompaniesBatchAsync

      public void updateCompaniesBatchAsync(List<CompanyModel> body, APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Update multiple Companies in a single batch async
      Specified by:
      updateCompaniesBatchAsync in interface IAPIController
      Parameters:
      body - The list of companies to update
      callBack - Called after the HTTP response is received
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error updating companies
    • updateSubscription

      public void updateSubscription(SubscriptionModel body) throws Throwable
      Update a Single Subscription
      Specified by:
      updateSubscription in interface IAPIController
      Parameters:
      body - The subscriptuon to update
      Throws:
      Throwable - on error creating event
    • updateSubscriptionAsync

      public void updateSubscriptionAsync(SubscriptionModel body, APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Update a Single Subscription async
      Specified by:
      updateSubscriptionAsync in interface IAPIController
      Parameters:
      body - The subscription to update
      callBack - Called after the HTTP response is received
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error creating event
    • updateSubscriptionsBatch

      public void updateSubscriptionsBatch(List<SubscriptionModel> body) throws Throwable
      Update multiple Subscriptions in a single batch
      Specified by:
      updateSubscriptionsBatch in interface IAPIController
      Parameters:
      body - The list of subscriptions to update
      Throws:
      Throwable - on error creating event
    • updateSubscriptionsBatchAsync

      public void updateSubscriptionsBatchAsync(List<SubscriptionModel> body, APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Update multiple Subscriptions in a single batch async
      Specified by:
      updateSubscriptionsBatchAsync in interface IAPIController
      Parameters:
      body - The list of subscriptions to update
      callBack - Called after the HTTP response is received
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error creating event
    • getAppConfig

      public HttpResponse getAppConfig() throws Throwable
      Get the Application config
      Specified by:
      getAppConfig in interface IAPIController
      Throws:
      Throwable - on error getting app config
    • getAppConfigAsync

      public void getAppConfigAsync(APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Get the Application config async
      Specified by:
      getAppConfigAsync in interface IAPIController
      Parameters:
      callBack - Called after the HTTP response is received
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error getting app config
    • getGovernanceRules

      public HttpResponse getGovernanceRules() throws Throwable
      Get the Governance rules
      Specified by:
      getGovernanceRules in interface IAPIController
      Throws:
      Throwable - on error getting app config
    • getGovernanceRulesAsync

      public void getGovernanceRulesAsync(APICallBack<HttpResponse> callBack) throws com.fasterxml.jackson.core.JsonProcessingException
      Get the Governance rules
      Specified by:
      getGovernanceRulesAsync in interface IAPIController
      Parameters:
      callBack - Called after the HTTP response is received
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on error getting app config
    • parseGovernanceRulesModel

      public List<GovernanceRulesModel> parseGovernanceRulesModel(InputStream jsonTxt) throws IOException
      Throws:
      IOException
    • parseAppConfigModel

      public AppConfigModel parseAppConfigModel(InputStream jsonTxt) throws IOException
      Throws:
      IOException
    • getDefaultAppConfig

      public AppConfigModel getDefaultAppConfig()
    • calculateWeight

      public int calculateWeight(int sampleRate)
    • buildEventModel

      public EventModel buildEventModel(EventRequestModel eventRequestModel, EventResponseModel eventResponseModel, String userId, String companyId, String sessionToken, String apiVersion, Object metadata, String direction)
    • isBlockedByGovernanceRules

      @Deprecated public boolean isBlockedByGovernanceRules(EventModel eventModel)
      Deprecated.
    • getBlockedByGovernanceRulesResponse

      public BlockedByGovernanceRulesResponse getBlockedByGovernanceRulesResponse(EventModel eventModel)
    • getBlockedByGovernanceRulesResponse

      public BlockedByGovernanceRulesResponse getBlockedByGovernanceRulesResponse(EventModel eventModel, List<GovernanceRulesModel> rules, AppConfigModel appConfig)
    • isBlockedByGovernanceRules

      @Deprecated public boolean isBlockedByGovernanceRules(EventModel eventModel, List<GovernanceRulesModel> rules, AppConfigModel appConfig)
      Deprecated.
    • shouldSendSampledEvent

      public boolean shouldSendSampledEvent(EventModel eventModel)
    • getSampleRateToUse

      public int getSampleRateToUse(EventModel eventModel)
    • getSampleRateToUse

      public int getSampleRateToUse(EventModel eventModel, AppConfigModel appConfigModel)