4
4
5
5
public class RestPostSubscriptionObject extends SubscriptionObject {
6
6
7
+ private final String NOTIFICATION_TYPE_KEY = "notificationType" ;
8
+ private final String NOTIFICATION_TYPE = "REST_POST" ;
9
+
10
+ private final String AUTHENTICATION_TYPE_KEY = "authenticationType" ;
11
+ private final String USERNAME_KEY = "userName" ;
12
+ private final String PASSWORD_KEY = "password" ;
13
+
14
+ private final String BASIC_AUTH = "BASIC_AUTH" ;
15
+
7
16
/**
8
17
* Creates a subscriptionObject with REST/POST capabilities.
9
18
* @param subscriptionName
@@ -12,17 +21,48 @@ public class RestPostSubscriptionObject extends SubscriptionObject {
12
21
public RestPostSubscriptionObject (String subscriptionName ) throws IOException {
13
22
super (subscriptionName );
14
23
15
- subscriptionJson .put ("notificationType" , "REST_POST" );
24
+ subscriptionJson .put (NOTIFICATION_TYPE_KEY , NOTIFICATION_TYPE );
16
25
}
17
26
18
27
/**
19
28
* Sets the field authenticationType to BASIC_AUTH together with the username and password.
20
29
* @param username
21
30
* @param password
22
31
*/
32
+ @ Deprecated
23
33
public void setBasicAuth (String username , String password ) {
24
- subscriptionJson .put ("userName" , username );
25
- subscriptionJson .put ("password" , password );
26
- subscriptionJson .put ("authenticationType" , "BASIC_AUTH" );
34
+ setAuthenticationType (BASIC_AUTH );
35
+ setUsername (username );
36
+ setPassword (password );
37
+ }
38
+
39
+ /**
40
+ * Sets the field authenticationType to given value
41
+ * @param authenticationType
42
+ * @return RestPostSubscriptionObject
43
+ */
44
+ public RestPostSubscriptionObject setAuthenticationType (String authenticationType ) {
45
+ subscriptionJson .put (AUTHENTICATION_TYPE_KEY , authenticationType );
46
+ return this ;
47
+ }
48
+
49
+ /**
50
+ * Sets the field username in a subscription.
51
+ * @param username
52
+ * @return RestPostSubscriptionObject
53
+ */
54
+ public RestPostSubscriptionObject setUsername (String username ) {
55
+ subscriptionJson .put (USERNAME_KEY , username );
56
+ return this ;
57
+ }
58
+
59
+ /**
60
+ * Sets the field password in a subscription.
61
+ * @param password
62
+ * @return RestPostSubscriptionObject
63
+ */
64
+ public RestPostSubscriptionObject setPassword (String password ) {
65
+ subscriptionJson .put (PASSWORD_KEY , password );
66
+ return this ;
27
67
}
28
68
}
0 commit comments