-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAddCallbackUrl.java
More file actions
70 lines (55 loc) · 2.48 KB
/
Copy pathAddCallbackUrl.java
File metadata and controls
70 lines (55 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.bunq.tinker;
import com.bunq.sdk.context.ApiEnvironmentType;
import com.bunq.sdk.model.core.NotificationFilterUrlUserInternal;
import com.bunq.sdk.model.generated.endpoint.NotificationFilterUrlUser;
import com.bunq.sdk.model.generated.object.NotificationFilterUrl;
import com.bunq.tinker.libs.BunqLib;
import com.bunq.tinker.libs.SharedLib;
import com.bunq.tinker.utils.ITinker;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import java.util.ArrayList;
import java.util.List;
public class AddCallbackUrl implements ITinker {
/**
* Notification filter constants.
*/
private static final String NOTIFICATION_CATEGORY_MUTATION = "MUTATION";
/**
* @param args
*
* @throws ParseException
*/
public void run(String[] args) throws ParseException {
CommandLine allOption = SharedLib.parseAllOption(args);
ApiEnvironmentType environmentType = SharedLib.determineEnvironmentType(allOption);
SharedLib.printHeader();
BunqLib bunq = new BunqLib(environmentType);
String callbackUrl = SharedLib.determineCallbackUrlFromAllOptionOrStdIn(allOption);
System.out.println();
System.out.println(" | Adding Callback URL: " + callbackUrl);
System.out.println();
System.out.println(" ...");
System.out.println();
List<NotificationFilterUrlUser> allNotificationFilterCurrent = NotificationFilterUrlUser.list().getValue();
List<NotificationFilterUrl> allNotificationFilterUpdated = new ArrayList<>();
for (NotificationFilterUrlUser notificationFilterUrlUser : allNotificationFilterCurrent) {
for (NotificationFilterUrl notificationFilterUrl : notificationFilterUrlUser.getNotificationFilters()) {
if (callbackUrl.equals(notificationFilterUrl.getNotificationTarget())) {
allNotificationFilterUpdated.add(notificationFilterUrl);
}
}
}
allNotificationFilterUpdated.add(
new NotificationFilterUrl(NOTIFICATION_CATEGORY_MUTATION, callbackUrl)
);
NotificationFilterUrlUserInternal.createWithListResponse(allNotificationFilterUpdated);
System.out.println();
System.out.println(" | ✅ Callback URL added");
System.out.println();
System.out.println(" | ▶️ Check your changed overview");
System.out.println();
System.out.println();
bunq.updateContext();
}
}