Package io.getlime.push.client
Class PushServerClient
java.lang.Object
io.getlime.push.client.PushServerClient
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
ConstructorsConstructorDescriptionPushServerClient(com.wultra.core.rest.client.base.RestClientConfiguration config, com.fasterxml.jackson.databind.Module... modules) Construct the push server client with the given configuration.PushServerClient(String serviceBaseUrl) Main constructor with the push server base URL. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddUsersToCampaign(Long campaignId, List<String> users) Add a list of users to a specific campaignio.getlime.core.rest.model.base.response.ObjectResponse<CreateApplicationResponse> createApplication(String appId) Create application credentials entity.io.getlime.core.rest.model.base.response.ObjectResponse<CreateCampaignResponse> createCampaign(String appId, PushMessageBody message) Create a campaign.booleancreateDevice(CreateDeviceRequest request) Register a device to the push server.booleancreateDevice(String appId, String token, MobilePlatform platform) Deprecated.booleancreateDevice(String appId, String token, MobilePlatform platform, String activationId) Deprecated.booleanRegister device associated with multiple activation IDs to the push server.booleancreateDeviceForActivations(String appId, String token, MobilePlatform platform, List<String> activationIds) Deprecated.booleandeleteCampaign(Long campaignId) Delete a campaign specified with campaignId.booleandeleteDevice(String 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<GetInboxMessageCountResponse> fetchMessageCountForUser(String userId, String appId) Fetch unread message count for a user with given ID.io.getlime.core.rest.model.base.response.ObjectResponse<GetInboxMessageDetailResponse> fetchMessageDetail(String inboxId) Fetch detail of the message for given message ID.fetchMessageListForUser(String userId, List<String> applications, boolean onlyUnread, Integer page, Integer size) Fetch the list of messages for a given user.io.getlime.core.rest.model.base.response.ObjectResponse<GetApplicationDetailResponse> Get detail for an application credentials entity.io.getlime.core.rest.model.base.response.ObjectResponse<GetApplicationListResponse> 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 paramgetListOfUsersFromCampaign(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> Returns service informationio.getlime.core.rest.model.base.response.ObjectResponse<GetApplicationListResponse> Get list of applications which are not yet configured in Push Server but exist in PowerAuth server.io.getlime.core.rest.model.base.response.ObjectResponse<GetInboxMessageDetailResponse> postMessage(CreateInboxMessageRequest request) Post a message to an inbox of provided user.io.getlime.core.rest.model.base.response.ResponsereadAllMessages(String userId, String appId) Read all unread messages in inbox of provided user.io.getlime.core.rest.model.base.response.ObjectResponse<GetInboxMessageDetailResponse> readMessage(String inboxId) Read message with given ID in inbox of provided user.io.getlime.core.rest.model.base.response.ResponseremoveAndroid(String appId) Deprecated.io.getlime.core.rest.model.base.response.ResponseremoveApns(String appId) Remove APNs record from an application credentials entity.io.getlime.core.rest.model.base.response.ResponseRemove FCM record from an application credentials entity.io.getlime.core.rest.model.base.response.ResponseRemove HMS record from an application credentials entity.io.getlime.core.rest.model.base.response.ResponseremoveHuawei(String appId) Deprecated.io.getlime.core.rest.model.base.response.ResponseDeprecated.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(String appId, PushMessage pushMessage) Send a single push message to application with given ID.io.getlime.core.rest.model.base.response.ObjectResponse<PushMessageSendResult> sendPushMessage(String appId, Mode mode, PushMessage pushMessage) Send a single push message to application with given ID.io.getlime.core.rest.model.base.response.ObjectResponse<PushMessageSendResult> sendPushMessageBatch(String appId, Mode mode, List<PushMessage> batch) Send a push message batch to application with given ID.io.getlime.core.rest.model.base.response.ObjectResponse<PushMessageSendResult> sendPushMessageBatch(String 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(String appId, String projectId, byte[] privateKey) Deprecated.io.getlime.core.rest.model.base.response.ResponseupdateApns(UpdateApnsRequest updateRequest) Update APNs details for an application credentials entity.booleanupdateDeviceStatus(String activationId) Update activation status for given device registration.io.getlime.core.rest.model.base.response.ResponseupdateFcm(UpdateFcmRequest updateRequest) Update FCM details for an application credentials entity.io.getlime.core.rest.model.base.response.ResponseupdateHms(UpdateHmsRequest request) Update HMS details for an application credentials entity.io.getlime.core.rest.model.base.response.ResponseupdateHuawei(UpdateHuaweiRequest request) Deprecated.io.getlime.core.rest.model.base.response.ResponseupdateIos(String appId, String bundle, String keyId, String teamId, ApnsEnvironment environment, byte[] privateKey) Deprecated.
-
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.
-
PushServerClient
public PushServerClient(com.wultra.core.rest.client.base.RestClientConfiguration config, com.fasterxml.jackson.databind.Module... modules) throws PushServerClientException Construct the push server client with the given configuration.- Parameters:
config- REST client configuration.modules- Optional jackson modules.- 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
@Deprecated public boolean createDevice(String appId, String token, MobilePlatform platform) throws PushServerClientException Deprecated.Register 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 (APNs, FCM, HMS).- Returns:
- True if device registration was successful, false otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
createDevice
@Deprecated public boolean createDevice(String appId, String token, MobilePlatform platform, String activationId) throws PushServerClientException Deprecated.Register 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 (APNs, FCM, HMS).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.
-
createDevice
Register a device to the push server.- Parameters:
request- Create device request.- Returns:
- True if device registration was successful, false otherwise.
- Throws:
PushServerClientException- In case of network, response / JSON processing, or other IO error.
-
createDeviceForActivations
@Deprecated public boolean createDeviceForActivations(String appId, String token, MobilePlatform platform, List<String> activationIds) throws PushServerClientException Deprecated.Register 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 (APNs, FCM, HMS).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.
-
createDeviceForActivations
public boolean createDeviceForActivations(CreateDeviceForActivationsRequest request) throws PushServerClientException Register device associated with multiple activation IDs to the push server.- Parameters:
request- Create device for activations request.- 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(String appId, PushMessage pushMessage) throws PushServerClientException Send 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.
-
sendPushMessage
public io.getlime.core.rest.model.base.response.ObjectResponse<PushMessageSendResult> sendPushMessage(String appId, Mode mode, PushMessage pushMessage) throws PushServerClientException Send a single push message to application with given ID.- Parameters:
appId- PowerAuth application app ID.mode- Mode of push notification sending.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(String appId, List<PushMessage> batch) throws PushServerClientException Send 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.
-
sendPushMessageBatch
public io.getlime.core.rest.model.base.response.ObjectResponse<PushMessageSendResult> sendPushMessageBatch(String appId, Mode mode, List<PushMessage> batch) throws PushServerClientException Send a push message batch to application with given ID.- Parameters:
appId- PowerAuth application app ID.mode- Mode of push notification sending.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(String appId, PushMessageBody message) throws PushServerClientException Create 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 PushServerClientException Get 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 PushServerClientException Get 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 PushServerClientException Add 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 PushServerClientException Get 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 PushServerClientException Delete 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(GetApplicationDetailRequest request) throws PushServerClientException Get detail for an application credentials entity.- Parameters:
request- Application detail request.- 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(String appId) throws PushServerClientException Create 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
@Deprecated public io.getlime.core.rest.model.base.response.Response updateIos(String appId, String bundle, String keyId, String teamId, ApnsEnvironment environment, byte[] privateKey) throws PushServerClientException Deprecated.Update iOS details for an application credentials entity.- Parameters:
appId- ID of application credentials entity.bundle- The iOS bundle record.keyId- The APNs key ID record.teamId- The Team ID record.environment- The APNs environment.privateKey- The APNs private key bytes.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
updateApns
public io.getlime.core.rest.model.base.response.Response updateApns(UpdateApnsRequest updateRequest) throws PushServerClientException Update APNs details for an application credentials entity.- Parameters:
updateRequest- Update APNS request.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
removeIos
@Deprecated public io.getlime.core.rest.model.base.response.Response removeIos(String appId) throws PushServerClientException Deprecated.Remove iOS record from an application credentials entity.- Parameters:
appId- Application credentials entity ID.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
removeApns
public io.getlime.core.rest.model.base.response.Response removeApns(String appId) throws PushServerClientException Remove APNs record from an application credentials entity.- Parameters:
appId- Application credentials entity ID.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
updateAndroid
@Deprecated public io.getlime.core.rest.model.base.response.Response updateAndroid(String appId, String projectId, byte[] privateKey) throws PushServerClientException Deprecated.Update Android details for an application credentials entity.- Parameters:
appId- 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.
-
updateFcm
public io.getlime.core.rest.model.base.response.Response updateFcm(UpdateFcmRequest updateRequest) throws PushServerClientException Update FCM details for an application credentials entity.- Parameters:
updateRequest- Update FCM request.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
removeAndroid
@Deprecated public io.getlime.core.rest.model.base.response.Response removeAndroid(String appId) throws PushServerClientException Deprecated.Remove Android record from an application credentials entity.- Parameters:
appId- Application credentials entity ID.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
removeFcm
public io.getlime.core.rest.model.base.response.Response removeFcm(String appId) throws PushServerClientException Remove FCM record from an application credentials entity.- Parameters:
appId- Application credentials entity ID.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
updateHuawei
@Deprecated public io.getlime.core.rest.model.base.response.Response updateHuawei(UpdateHuaweiRequest request) throws PushServerClientException Deprecated.Update Huawei details for an application credentials entity.- Parameters:
request- Update Huawei request.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
updateHms
public io.getlime.core.rest.model.base.response.Response updateHms(UpdateHmsRequest request) throws PushServerClientException Update HMS details for an application credentials entity.- Parameters:
request- Update HMS request.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
removeHuawei
@Deprecated public io.getlime.core.rest.model.base.response.Response removeHuawei(String appId) throws PushServerClientException Deprecated.Remove Huawei record from an application credentials entity.- Parameters:
appId- Application credentials entity ID.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
removeHms
public io.getlime.core.rest.model.base.response.Response removeHms(String appId) throws PushServerClientException Remove HMS record from an application credentials entity.- Parameters:
appId- Application credentials entity ID.- Returns:
- Response from server.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
postMessage
public io.getlime.core.rest.model.base.response.ObjectResponse<GetInboxMessageDetailResponse> postMessage(CreateInboxMessageRequest request) throws PushServerClientException Post a message to an inbox of provided user.- Parameters:
request- Request with the message detail.- Returns:
- Response with a newly created message.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
fetchMessageListForUser
public PagedResponse<ListOfInboxMessages> fetchMessageListForUser(String userId, List<String> applications, boolean onlyUnread, Integer page, Integer size) throws PushServerClientException Fetch the list of messages for a given user.- Parameters:
userId- User ID.applications- List of application IDs.onlyUnread- Indication if only unread messages should be returneed.page- Page index.size- Page size.- Returns:
- List of inbox messages.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
fetchMessageCountForUser
public io.getlime.core.rest.model.base.response.ObjectResponse<GetInboxMessageCountResponse> fetchMessageCountForUser(String userId, String appId) throws PushServerClientException Fetch unread message count for a user with given ID.- Parameters:
userId- User ID.appId- Application ID.- Returns:
- Count of unread messages.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
readAllMessages
public io.getlime.core.rest.model.base.response.Response readAllMessages(String userId, String appId) throws PushServerClientException Read all unread messages in inbox of provided user.- Parameters:
userId- User ID.appId- Application ID.- Returns:
- Response.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
fetchMessageDetail
public io.getlime.core.rest.model.base.response.ObjectResponse<GetInboxMessageDetailResponse> fetchMessageDetail(String inboxId) throws PushServerClientException Fetch detail of the message for given message ID.- Parameters:
inboxId- Inbox message ID.- Returns:
- Detail of a message with given ID.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
readMessage
public io.getlime.core.rest.model.base.response.ObjectResponse<GetInboxMessageDetailResponse> readMessage(String inboxId) throws PushServerClientException Read message with given ID in inbox of provided user.- Parameters:
inboxId- Inbox message ID.- Returns:
- Detail of the read message.
- Throws:
PushServerClientException- Thrown when communication with Push Server fails.
-
createDevice(CreateDeviceRequest)