Skip to content

Commit

Permalink
fix: calcom user endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: PhilippFruh <[email protected]>
  • Loading branch information
PhilippFr committed Jul 6, 2022
1 parent 4b56314 commit c7bc8c9
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public CalComUserService(RestTemplate restTemplate, @Value("${calcom.apiUrl}") S
// Users
public List<CalcomUser> getUsers() throws JsonProcessingException {
// ResponseEntity<CalcomUser[]> response = restTemplate.getForEntity(String.format(this.buildUri("/users"), calcomApiUrl, calcomApiKey), CalcomUser[].class);

String response = this.restTemplate.getForObject(String.format(this.buildUri("/v1/users"), calcomApiUrl, calcomApiKey), String.class);
JSONObject jsonObject = new JSONObject(response);
log.debug(String.valueOf(jsonObject));
Expand All @@ -43,21 +42,21 @@ public List<CalcomUser> getUsers() throws JsonProcessingException {
public CalcomUser createUser(JSONObject user) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
log.debug("Creating calcom user: {}", user);
log.info("Creating calcom user: {}", user);
HttpEntity<String> request = new HttpEntity<>(user.toString(), headers);
return restTemplate.postForEntity(this.buildUri("/v1/user"), request, CalcomUser.class).getBody();
return restTemplate.postForEntity(this.buildUri("/v1/users"), request, CalcomUser.class).getBody();
}

public CalcomUser updateUser(JSONObject user) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
log.debug("Updating calcom user: {}", user);
log.info("Updating calcom user: {}", user);
HttpEntity<String> request = new HttpEntity<>(user.toString(), headers);
return restTemplate.postForEntity(this.buildUri("/v1/user/" + user.getLong("id")), request, CalcomUser.class).getBody();
return restTemplate.postForEntity(this.buildUri("/v1/users/" + user.getLong("id")), request, CalcomUser.class).getBody();
}

public HttpStatus deleteUser(Long userId) {
return restTemplate.exchange(this.buildUri("/v1/user/" + userId), HttpMethod.DELETE, null, String.class).getStatusCode();
return restTemplate.exchange(this.buildUri("/v1/users/" + userId), HttpMethod.DELETE, null, String.class).getStatusCode();
}


Expand Down

0 comments on commit c7bc8c9

Please sign in to comment.