-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathHttpSettings.java
More file actions
46 lines (39 loc) · 1.62 KB
/
HttpSettings.java
File metadata and controls
46 lines (39 loc) · 1.62 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
package solutions.bellatrix.data.http.configuration;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import solutions.bellatrix.core.configuration.ConfigurationService;
import solutions.bellatrix.data.configuration.DataSettings;
import solutions.bellatrix.data.http.authentication.Authentication;
import solutions.bellatrix.data.http.authentication.AuthenticationMethod;
import java.util.function.Consumer;
@Data
public class HttpSettings {
@SerializedName("baseUrl")
private String baseUrl;
@SerializedName("basePath")
private String basePath;
@SerializedName("contentType")
private String contentType;
@SerializedName("authentication")
private Authentication authentication;
@SerializedName("urlEncoderEnabled")
private boolean urlEncoderEnabled;
public HttpSettings(HttpSettings httpSettings) {
setBaseUrl(httpSettings.getBaseUrl());
setBasePath(httpSettings.getBasePath());
setContentType(httpSettings.getContentType());
setUrlEncoderEnabled(httpSettings.isUrlEncoderEnabled());
setAuthentication(httpSettings.getAuthentication());
}
public static HttpSettings custom(Consumer<HttpSettings> httpSettings) {
var settings = ConfigurationService.get(DataSettings.class).getHttpSettings();
if (settings == null) {
throw new IllegalStateException("Include the httpSettings section in your config file");
}
httpSettings.accept(settings);
return settings;
}
public AuthenticationMethod getAuthenticationMethod() {
return authentication.getAuthenticationMethod();
}
}