Search in sources :

Example 6 with User

use of uk.nhs.digital.intranet.json.User in project hippo by NHS-digital-website.

the class GraphProviderImpl method getUser.

private User getUser(final String id) throws ProviderCommunicationException {
    final HttpEntity<String> httpRequest = getHttpRequest(MediaType.APPLICATION_JSON);
    final URI uri = UriComponentsBuilder.fromUriString(BASE_URL_V1).pathSegment("users").pathSegment(id).queryParam("$select", SELECTED_FIELDS_LONG).build().toUri();
    try {
        final ResponseEntity<User> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, httpRequest, User.class);
        Assert.notNull(responseEntity.getBody(), "Received null response from Microsoft Graph API.");
        return responseEntity.getBody();
    } catch (final HttpStatusCodeException e) {
        LOGGER.error("Received exception with status {} from Microsoft Graph API.", e.getStatusCode(), e);
        throw new ProviderCommunicationException();
    }
}
Also used : ProviderCommunicationException(uk.nhs.digital.intranet.model.exception.ProviderCommunicationException) User(uk.nhs.digital.intranet.json.User) HttpStatusCodeException(org.springframework.web.client.HttpStatusCodeException) URI(java.net.URI)

Aggregations

User (uk.nhs.digital.intranet.json.User)6 Test (org.junit.Test)3 Person (uk.nhs.digital.intranet.model.Person)3 URI (java.net.URI)1 HttpStatusCodeException (org.springframework.web.client.HttpStatusCodeException)1 ProviderCommunicationException (uk.nhs.digital.intranet.model.exception.ProviderCommunicationException)1