class AzurePhotoFetcher {

  String getPhotoForUserId(String auth, UUID userId) throws AzureUserFetchException {
    try {
      URL url = new URL("https://graph.microsoft.com/v1.0/users/" + userId + "/photo/$value");
      InputStream inputStream = azureApiCaller.callApi(auth, url);
      BufferedImage photo = getPhotoAsImage(inputStream);
      photo = resizeImage(photo, 240, 240);
      return convertImageToBase64(photo);
    } catch (IOException e) {
      throw new AzureUserFetchException(e.getMessage());
    } catch (IllegalStateException e) {
      return null; // No photo found for the user.
    }
  }

  @Autowired public  AzurePhotoFetcher(AzureApiCaller azureApiCaller);

}