Skip to content

Commit fda2320

Browse files
committed
fix: update get acknowledgement
Signed-off-by: Ákos Sztremi <Akos.Sztremi@ibm.com>
1 parent d432a72 commit fda2320

13 files changed

Lines changed: 632 additions & 627 deletions

File tree

modules/examples/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsExamples.java

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,63 @@ public static void main(String[] args) throws Exception {
8484
String destinationId = testConfigProperties.get("DESTINATION_ID");
8585
String iamId = testConfigProperties.get("IAM_ID");
8686

87+
try {
88+
System.out.println("listNotifications() result:");
89+
// begin-list_notifications
90+
ListNotificationsOptions listNotificationsOptions = new ListNotificationsOptions.Builder()
91+
.accountId(accountId)
92+
.limit(Long.valueOf("50"))
93+
.build();
94+
95+
NotificationsPager pager = new NotificationsPager(platformNotificationsService, listNotificationsOptions);
96+
List<Notification> allResults = new ArrayList<>();
97+
while (pager.hasNext()) {
98+
List<Notification> nextPage = pager.getNext();
99+
allResults.addAll(nextPage);
100+
}
101+
102+
System.out.println(GsonSingleton.getGson().toJson(allResults));
103+
// end-list_notifications
104+
} catch (ServiceResponseException e) {
105+
logger.error(String.format("Service returned status code %s: %s%nError details: %s",
106+
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
107+
}
108+
109+
try {
110+
System.out.println("getAcknowledgement() result:");
111+
// begin-get_acknowledgement
112+
GetAcknowledgementOptions getAcknowledgementOptions = new GetAcknowledgementOptions.Builder()
113+
.accountId(accountId)
114+
.build();
115+
116+
Response<Acknowledgement> response = platformNotificationsService.getAcknowledgement(getAcknowledgementOptions).execute();
117+
Acknowledgement acknowledgement = response.getResult();
118+
119+
System.out.println(acknowledgement);
120+
// end-get_acknowledgement
121+
} catch (ServiceResponseException e) {
122+
logger.error(String.format("Service returned status code %s: %s%nError details: %s",
123+
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
124+
}
125+
126+
try {
127+
System.out.println("replaceNotificationAcknowledgement() result:");
128+
// begin-replace_notification_acknowledgement
129+
ReplaceNotificationAcknowledgementOptions replaceNotificationAcknowledgementOptions = new ReplaceNotificationAcknowledgementOptions.Builder()
130+
.lastAcknowledged(Long.valueOf("1772804159452"))
131+
.accountId(accountId)
132+
.build();
133+
134+
Response<Acknowledgement> response = platformNotificationsService.replaceNotificationAcknowledgement(replaceNotificationAcknowledgementOptions).execute();
135+
Acknowledgement acknowledgement = response.getResult();
136+
137+
System.out.println(acknowledgement);
138+
// end-replace_notification_acknowledgement
139+
} catch (ServiceResponseException e) {
140+
logger.error(String.format("Service returned status code %s: %s%nError details: %s",
141+
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
142+
}
143+
87144
try {
88145
System.out.println("listDistributionListDestinations() result:");
89146
// begin-list_distribution_list_destinations
@@ -236,63 +293,6 @@ public static void main(String[] args) throws Exception {
236293
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
237294
}
238295

239-
try {
240-
System.out.println("listNotifications() result:");
241-
// begin-list_notifications
242-
ListNotificationsOptions listNotificationsOptions = new ListNotificationsOptions.Builder()
243-
.accountId(accountId)
244-
.limit(Long.valueOf("50"))
245-
.build();
246-
247-
NotificationsPager pager = new NotificationsPager(platformNotificationsService, listNotificationsOptions);
248-
List<Notification> allResults = new ArrayList<>();
249-
while (pager.hasNext()) {
250-
List<Notification> nextPage = pager.getNext();
251-
allResults.addAll(nextPage);
252-
}
253-
254-
System.out.println(GsonSingleton.getGson().toJson(allResults));
255-
// end-list_notifications
256-
} catch (ServiceResponseException e) {
257-
logger.error(String.format("Service returned status code %s: %s%nError details: %s",
258-
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
259-
}
260-
261-
try {
262-
System.out.println("getAcknowledgement() result:");
263-
// begin-get_acknowledgement
264-
GetAcknowledgementOptions getAcknowledgementOptions = new GetAcknowledgementOptions.Builder()
265-
.accountId(accountId)
266-
.build();
267-
268-
Response<Acknowledgement> response = platformNotificationsService.getAcknowledgement(getAcknowledgementOptions).execute();
269-
Acknowledgement acknowledgement = response.getResult();
270-
271-
System.out.println(acknowledgement);
272-
// end-get_acknowledgement
273-
} catch (ServiceResponseException e) {
274-
logger.error(String.format("Service returned status code %s: %s%nError details: %s",
275-
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
276-
}
277-
278-
try {
279-
System.out.println("replaceNotificationAcknowledgement() result:");
280-
// begin-replace_notification_acknowledgement
281-
ReplaceNotificationAcknowledgementOptions replaceNotificationAcknowledgementOptions = new ReplaceNotificationAcknowledgementOptions.Builder()
282-
.lastAcknowledgedId("1777909855390")
283-
.accountId(accountId)
284-
.build();
285-
286-
Response<Acknowledgement> response = platformNotificationsService.replaceNotificationAcknowledgement(replaceNotificationAcknowledgementOptions).execute();
287-
Acknowledgement acknowledgement = response.getResult();
288-
289-
System.out.println(acknowledgement);
290-
// end-replace_notification_acknowledgement
291-
} catch (ServiceResponseException e) {
292-
logger.error(String.format("Service returned status code %s: %s%nError details: %s",
293-
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
294-
}
295-
296296
try {
297297
// begin-delete_distribution_list_destination
298298
DeleteDistributionListDestinationOptions deleteDistributionListDestinationOptions = new DeleteDistributionListDestinationOptions.Builder()

0 commit comments

Comments
 (0)