Package com.moesif.api.controllers
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
-
-
Field Summary
-
Fields inherited from class com.moesif.api.controllers.BaseController
httpCallBack
-
-
Constructor Summary
Constructors Constructor Description APIController()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EventModelbuildEventModel(EventRequestModel eventRequestModel, EventResponseModel eventResponseModel, String userId, String companyId, String sessionToken, String apiVersion, Object metadata, String direction)intcalculateWeight(int sampleRate)Map<String,String>createEvent(EventModel body)Add Single API Event CallvoidcreateEventAsync(EventModel body, APICallBack<HttpResponse> callBack)Add Single API Event CallMap<String,String>createEventsBatch(List<EventModel> body)Add multiple API Events in a single batchvoidcreateEventsBatchAsync(List<EventModel> body, APICallBack<HttpResponse> callBack)Add multiple API Events in a single batchHttpResponsegetAppConfig()Get the Application configvoidgetAppConfigAsync(APICallBack<HttpResponse> callBack)Get the Application config asyncAppConfigModelgetDefaultAppConfig()HttpResponsegetGovernanceRules()Get the Governance rulesvoidgetGovernanceRulesAsync(APICallBack<HttpResponse> callBack)Get the Governance rulesstatic APIControllergetInstance()Singleton pattern implementationintgetSampleRateToUse(EventModel eventModel)static AppConfigModelparseAppConfigModel(InputStream jsonTxt)static List<GovernanceRulesModel>parseGovernanceRulesModel(InputStream jsonTxt)voidsetAppConfig(AppConfigModel config)voidsetShouldSyncAppConfig(boolean shouldSync)booleanshouldSendSampledEvent()booleanshouldSendSampledEvent(EventModel eventModel)voidupdateCompaniesBatch(List<CompanyModel> body)Update multiple Companies in a single batchvoidupdateCompaniesBatchAsync(List<CompanyModel> body, APICallBack<HttpResponse> callBack)Update multiple Companies in a single batch asyncvoidupdateCompany(CompanyModel body)Update a Single CompanyvoidupdateCompanyAsync(CompanyModel body, APICallBack<HttpResponse> callBack)Update a Single Company asyncvoidupdateUser(UserModel body)Update a Single UservoidupdateUserAsync(UserModel body, APICallBack<HttpResponse> callBack)Update a Single User asyncvoidupdateUsersBatch(List<UserModel> body)Update multiple Users in a single batchvoidupdateUsersBatchAsync(List<UserModel> body, APICallBack<HttpResponse> callBack)Update multiple Users in a single batch async-
Methods inherited from class com.moesif.api.controllers.BaseController
getClientInstance, getHttpCallBack, setClientInstance, setHttpCallBack, validateResponse
-
-
-
-
Method Detail
-
getInstance
public static APIController getInstance()
Singleton pattern implementation- Returns:
- The singleton instance of the APIController class
-
createEvent
public Map<String,String> createEvent(EventModel body) throws Throwable
Add Single API Event Call- Specified by:
createEventin interfaceIAPIController- 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:
createEventAsyncin interfaceIAPIController- Parameters:
body- The event to createcallBack- 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:
createEventsBatchin interfaceIAPIController- 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
Add multiple API Events in a single batch- Specified by:
createEventsBatchAsyncin interfaceIAPIController- Parameters:
body- The events to createcallBack- Called after the HTTP response is received- Throws:
com.fasterxml.jackson.core.JsonProcessingException- on error creating event
-
updateUser
public void updateUser(UserModel body) throws Throwable
Update a Single User- Specified by:
updateUserin interfaceIAPIController- 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:
updateUserAsyncin interfaceIAPIController- Parameters:
body- The user to updatecallBack- 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:
updateUsersBatchin interfaceIAPIController- 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:
updateUsersBatchAsyncin interfaceIAPIController- Parameters:
body- The list of users to updatecallBack- 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:
updateCompanyin interfaceIAPIController- 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:
updateCompanyAsyncin interfaceIAPIController- Parameters:
body- The company to updatecallBack- 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:
updateCompaniesBatchin interfaceIAPIController- 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:
updateCompaniesBatchAsyncin interfaceIAPIController- Parameters:
body- The list of companies to updatecallBack- Called after the HTTP response is received- Throws:
com.fasterxml.jackson.core.JsonProcessingException- on error updating companies
-
getAppConfig
public HttpResponse getAppConfig() throws Throwable
Get the Application config- Specified by:
getAppConfigin interfaceIAPIController- 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:
getAppConfigAsyncin interfaceIAPIController- 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:
getGovernanceRulesin interfaceIAPIController- 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:
getGovernanceRulesAsyncin interfaceIAPIController- Parameters:
callBack- Called after the HTTP response is received- Throws:
com.fasterxml.jackson.core.JsonProcessingException- on error getting app config
-
setAppConfig
public void setAppConfig(AppConfigModel config)
-
setShouldSyncAppConfig
public void setShouldSyncAppConfig(boolean shouldSync)
-
parseGovernanceRulesModel
public static List<GovernanceRulesModel> parseGovernanceRulesModel(InputStream jsonTxt) throws IOException
- Throws:
IOException
-
parseAppConfigModel
public static 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)
-
shouldSendSampledEvent
public boolean shouldSendSampledEvent()
-
shouldSendSampledEvent
public boolean shouldSendSampledEvent(EventModel eventModel)
-
getSampleRateToUse
public int getSampleRateToUse(EventModel eventModel)
-
-