Package io.getlime.push.client
Class PushServerClient
java.lang.Object
io.getlime.push.client.PushServerClient
public class PushServerClient extends Object
Simple class for interacting with the push server RESTful API.
- Author:
- Petr Dvorak, petr@wultra.com, Martin Tupy, martin.tupy.work@gmail.com
-
Constructor Summary
Constructors Constructor Description PushServerClient(String serviceBaseUrl)Main constructor with the push server base URL. -
Method Summary
Modifier and Type Method Description booleanaddUsersToCampaign(Long campaignId, List<String> users)Add a list of users to a specific campaignio.getlime.core.rest.model.base.response.ObjectResponse<CreateApplicationResponse>createApplication(Long appId)Create application credentials entity.io.getlime.core.rest.model.base.response.ObjectResponse<CreateCampaignResponse>createCampaign(Long appId, PushMessageBody message)Create a campaign.booleancreateDevice(Long appId, String token, MobilePlatform platform)Register anonymous device to the push server.booleancreateDevice(Long appId, String token, MobilePlatform platform, String activationId)Register device associated with activation ID to the push server.booleancreateDeviceForActivations(Long appId, String token, MobilePlatform platform, List<String> activationIds)Register device associated with multiple activation IDs to the push server.booleandeleteCampaign(Long campaignId)Delete a campaign specified with campaignId.booleandeleteDevice(Long appId, String token)Remove device from the push serverbooleandeleteUsersFromCampaign(Long campaignId, List<String> users)Delete a list of users from specific campaign.io.getlime.core.rest.model.base.response.ObjectResponse<GetApplicationDetailResponse>getApplicationDetail(Long id, boolean includeIos, boolean includeAndroid)Get detail for an application credentials entity.io.getlime.core.rest.model.base.response.ObjectResponse<GetApplicationListResponse>getApplicationList()Get list of application credentials entities.io.getlime.core.rest.model.base.response.ObjectResponse<CampaignResponse>getCampaign(Long campaignId)Get a campaign specified with campaignID.io.getlime.core.rest.model.base.response.ObjectResponse<ListOfCampaignsResponse>getListOfCampaigns(boolean all)Get list of campaigns, dependent on all paramPagedResponse<ListOfUsersFromCampaignResponse>getListOfUsersFromCampaign(Long campaignId, int page, int size)Get a list of users in paged format from specific campaignio.getlime.core.rest.model.base.response.ObjectResponse<ServiceStatusResponse>getServiceStatus()Returns service informationio.getlime.core.rest.model.base.response.ObjectResponse<GetApplicationListResponse>getUnconfiguredApplicationList()Get list of applications which are not yet configured in Push Server but exist in PowerAuth server.io.getlime.core.rest.model.base.response.ResponseremoveAndroid(Long id)Remove Android record from an application credentials entity.io.getlime.core.rest.model.base.response.ResponseremoveIos(Long id)Remove iOS record from an application credentials entity.booleansendCampaign(Long campaignId)Send a specific campaign to users carrying this campaignID in PushCampaignUser model, but only once per device identified by token.io.getlime.core.rest.model.base.response.ObjectResponse<PushMessageSendResult>sendPushMessage(Long appId, PushMessage pushMessage)Send a single push message to application with given ID.io.getlime.core.rest.model.base.response.ObjectResponse<PushMessageSendResult>sendPushMessageBatch(Long appId, List<PushMessage> batch)Send a push message batch to application with given ID.booleansendTestCampaign(Long campaignId, String userId)Send a campaign on test user for trying its correctness.io.getlime.core.rest.model.base.response.ResponseupdateAndroid(Long id, String projectId, byte[] privateKey)Update Android details for an application credentials entity.booleanupdateDeviceStatus(String activationId)Update activation status for given device registration.io.getlime.core.rest.model.base.response.ResponseupdateIos(Long id, String bundle, String keyId, String teamId, byte[] privateKey)Update iOS details for an application credentials entity.
-
Constructor Details
-
PushServerClient
Main constructor with the push server base URL.- Parameters:
serviceBaseUrl- Push server instance base URL.- Throws:
PushServerClientException- Thrown in case REST client initialization fails.
-
-
Method Details
-
getServiceStatus
public io.getlime.core.rest.model.base.response.ObjectResponse<ServiceStatusResponse> getServiceStatus() throws PushServerClientExceptionReturns service information- Returns:
- True if service is running.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
createDevice
public boolean createDevice(Long appId, String token, MobilePlatform platform) throws PushServerClientExceptionRegister anonymous device to the push server.- Parameters:
appId- PowerAuth application app ID.token- Token received from the push service provider (APNs, FCM).platform- Mobile platform (iOS, Android).- Returns:
- True if device registration was successful, false otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
createDevice
public boolean createDevice(Long appId, String token, MobilePlatform platform, String activationId) throws PushServerClientExceptionRegister device associated with activation ID to the push server.- Parameters:
appId- PowerAuth application app ID.token- Token received from the push service provider (APNs, FCM).platform- Mobile platform (iOS, Android).activationId- PowerAuth activation ID.- Returns:
- True if device registration was successful, false otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
createDeviceForActivations
public boolean createDeviceForActivations(Long appId, String token, MobilePlatform platform, List<String> activationIds) throws PushServerClientExceptionRegister device associated with multiple activation IDs to the push server.- Parameters:
appId- PowerAuth application app ID.token- Token received from the push service provider (APNs, FCM).platform- Mobile platform (iOS, Android).activationIds- PowerAuth activation IDs.- Returns:
- True if device registration was successful, false otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
deleteDevice
Remove device from the push server- Parameters:
appId- PowerAuth application app ID.token- Token received from the push service provider.- Returns:
- True if device removal was successful, false otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
updateDeviceStatus
Update activation status for given device registration.- Parameters:
activationId- Identifier of activation- Returns:
- True if updating went successful, false otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
sendPushMessage
public io.getlime.core.rest.model.base.response.ObjectResponse<PushMessageSendResult> sendPushMessage(Long appId, PushMessage pushMessage) throws PushServerClientExceptionSend a single push message to application with given ID.- Parameters:
appId- PowerAuth application app ID.pushMessage- Push message to be sent.- Returns:
- SendMessageResponse in case everything went OK, ErrorResponse in case of an error.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
sendPushMessageBatch
public io.getlime.core.rest.model.base.response.ObjectResponse<PushMessageSendResult> sendPushMessageBatch(Long appId, List<PushMessage> batch) throws PushServerClientExceptionSend a push message batch to application with given ID.- Parameters:
appId- PowerAuth application app ID.batch- Push message batch to be sent.- Returns:
- SendMessageResponse in case everything went OK, ErrorResponse in case of an error.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
createCampaign
public io.getlime.core.rest.model.base.response.ObjectResponse<CreateCampaignResponse> createCampaign(Long appId, PushMessageBody message) throws PushServerClientExceptionCreate a campaign.- Parameters:
appId- Application ID.message- Message which attributes are defined in PushMessageBody.- Returns:
- ID of new created campaign.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
deleteCampaign
Delete a campaign specified with campaignId.- Parameters:
campaignId- Campaign ID.- Returns:
- True if campaign is removed, false otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
getListOfCampaigns
public io.getlime.core.rest.model.base.response.ObjectResponse<ListOfCampaignsResponse> getListOfCampaigns(boolean all) throws PushServerClientExceptionGet list of campaigns, dependent on all param- Parameters:
all- true to get whole list, false to get campaigns that are only sent- Returns:
- List of campaigns.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
getCampaign
public io.getlime.core.rest.model.base.response.ObjectResponse<CampaignResponse> getCampaign(Long campaignId) throws PushServerClientExceptionGet a campaign specified with campaignID.- Parameters:
campaignId- ID of campaign to get.- Returns:
- Details of campaign, defined in CampaignResponse
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
addUsersToCampaign
public boolean addUsersToCampaign(Long campaignId, List<String> users) throws PushServerClientExceptionAdd a list of users to a specific campaign- Parameters:
campaignId- Identifier of campaign.users- List of users to add.- Returns:
- True if adding was successful, false otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
getListOfUsersFromCampaign
public PagedResponse<ListOfUsersFromCampaignResponse> getListOfUsersFromCampaign(Long campaignId, int page, int size) throws PushServerClientExceptionGet a list of users in paged format from specific campaign- Parameters:
campaignId- Identifier of campaign.page- Page number.size- Size of elements per page.- Returns:
- Page of users specified with params.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
deleteUsersFromCampaign
public boolean deleteUsersFromCampaign(Long campaignId, List<String> users) throws PushServerClientExceptionDelete a list of users from specific campaign.- Parameters:
campaignId- Identifier of campaign.users- List of users' Identifiers to delete.- Returns:
- True if deletion was successful, false otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
sendTestCampaign
Send a campaign on test user for trying its correctness.- Parameters:
campaignId- Identifier of campaign.userId- Identifier of test user.- Returns:
- True if sent, else otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
sendCampaign
Send a specific campaign to users carrying this campaignID in PushCampaignUser model, but only once per device identified by token.- Parameters:
campaignId- Identifier of campaign.- Returns:
- True if sent, else otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
getApplicationList
public io.getlime.core.rest.model.base.response.ObjectResponse<GetApplicationListResponse> getApplicationList() throws PushServerClientExceptionGet list of application credentials entities.- Returns:
- Application credentials entity list.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
getUnconfiguredApplicationList
public io.getlime.core.rest.model.base.response.ObjectResponse<GetApplicationListResponse> getUnconfiguredApplicationList() throws PushServerClientExceptionGet list of applications which are not yet configured in Push Server but exist in PowerAuth server.- Returns:
- List of applications which are not configured.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
getApplicationDetail
public io.getlime.core.rest.model.base.response.ObjectResponse<GetApplicationDetailResponse> getApplicationDetail(Long id, boolean includeIos, boolean includeAndroid) throws PushServerClientExceptionGet detail for an application credentials entity.- Parameters:
id- Application credentials entity ID.includeIos- Whether to include iOS details.includeAndroid- Whether to include Android details.- Returns:
- Application credentials entity detail.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
createApplication
public io.getlime.core.rest.model.base.response.ObjectResponse<CreateApplicationResponse> createApplication(Long appId) throws PushServerClientExceptionCreate application credentials entity.- Parameters:
appId- PowerAuth application ID.- Returns:
- Response with ID of created application credentials entity.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
updateIos
public io.getlime.core.rest.model.base.response.Response updateIos(Long id, String bundle, String keyId, String teamId, byte[] privateKey) throws PushServerClientExceptionUpdate iOS details for an application credentials entity.- Parameters:
id- ID of application credentials entity.bundle- The iOS bundle record.keyId- The iOS key record.teamId- The iOS team ID record.privateKey- The iOS private key bytes.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
removeIos
public io.getlime.core.rest.model.base.response.Response removeIos(Long id) throws PushServerClientExceptionRemove iOS record from an application credentials entity.- Parameters:
id- Application credentials entity ID.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
updateAndroid
public io.getlime.core.rest.model.base.response.Response updateAndroid(Long id, String projectId, byte[] privateKey) throws PushServerClientExceptionUpdate Android details for an application credentials entity.- Parameters:
id- Application credentials entity ID.projectId- The Android project ID record.privateKey- The Android private key bytes.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
removeAndroid
public io.getlime.core.rest.model.base.response.Response removeAndroid(Long id) throws PushServerClientExceptionRemove Android record from an application credentials entity.- Parameters:
id- Application credentials entity ID.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-