Skip to content

Commit

Permalink
Aligned RelewiseClient with new parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
KSGRelewise committed Aug 8, 2024
1 parent 44fc285 commit a83b196
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,34 @@
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.Properties;
import java.util.function.Supplier;

public class RelewiseClient {
public String serverUrl = "https://api.relewise.com";
private static final String apiVersion = "v1";
private static final String clientName = "RelewiseJavaClient";
private String clientVersion = "unknown";
private final String datasetId;
private final String apiKey;
private final String serverUrl;
private final int timeout;
private final ObjectMapper objectMapper;

public RelewiseClient(String datasetId, String apiKey) {
public RelewiseClient(String datasetId, String apiKey, String serverUrl, int timeout) {
this.datasetId = datasetId;
this.apiKey = apiKey;
this.serverUrl = serverUrl;
this.timeout = timeout;

this.objectMapper = JsonMapper.builder()
.addModule(new JavaTimeModule())
.build();

try {
Properties properties = new Properties();
properties.load(this.getClass().getClassLoader().getResourceAsStream("project.properties"));
clientVersion = properties.getProperty("version");
this.clientVersion = properties.getProperty("version");
} catch (IOException e) {
// We intentionally swallow this exception as we don't want users code to throw exceptions if this is not successful.
}
Expand All @@ -51,6 +56,7 @@ public HttpResponse<String> makeRequestAsync(String endpoint, LicensedRequest re
.header("Authorization", "ApiKey " + apiKey)
.header("Content-Type", "application/json")
.header("User-Agent", clientName + "/" + clientVersion)
.timeout(Duration.ofSeconds(timeout))
.build();

var httpClient = HttpClient.newHttpClient();
Expand Down

0 comments on commit a83b196

Please sign in to comment.