-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMatchNotification.java
More file actions
107 lines (76 loc) · 2.54 KB
/
MatchNotification.java
File metadata and controls
107 lines (76 loc) · 2.54 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.yoti.api.client.identity;
import static com.yoti.api.client.spi.remote.call.HttpMethod.SUPPORTED_HTTP_METHODS;
import java.net.URI;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import com.yoti.validation.Validation;
import com.fasterxml.jackson.annotation.JsonProperty;
public final class MatchNotification {
@JsonProperty(Property.URL)
private final String endpoint;
@JsonProperty(Property.METHOD)
private final String method;
@JsonProperty(Property.VERIFY_TLS)
private final boolean verifyTls;
@JsonProperty(Property.HEADERS)
private final Map<String, String> headers;
private MatchNotification(Builder builder) {
endpoint = builder.endpoint;
method = builder.method;
verifyTls = builder.verifyTls;
headers = builder.headers;
}
public String getEndpoint() {
return endpoint;
}
public String getMethod() {
return method;
}
public boolean isVerifyTls() {
return verifyTls;
}
public Map<String, String> getHeaders() {
return headers;
}
public static Builder forUrl(URI uri) {
return new Builder(uri);
}
public static final class Builder {
private final String endpoint;
private final Map<String, String> headers;
private String method;
private boolean verifyTls;
private Builder(URI uri) {
Validation.notNull(uri, Property.URL);
endpoint = uri.toString();
headers = new HashMap<>();
}
public Builder withMethod(String method) {
Validation.withinList(method.toUpperCase(Locale.ROOT), SUPPORTED_HTTP_METHODS);
this.method = method;
return this;
}
public Builder withVerifyTls(boolean verifyTls) {
this.verifyTls = verifyTls;
return this;
}
public Builder withHeaders(Map<String, String> headers) {
this.headers.putAll(headers);
return this;
}
public Builder withHeader(String key, String value) {
headers.put(key, value);
return this;
}
public MatchNotification build() {
return new MatchNotification(this);
}
}
private static final class Property {
private static final String URL = "url";
private static final String METHOD = "method";
private static final String VERIFY_TLS = "verifyTls";
private static final String HEADERS = "headers";
}
}