class DelfiSubmitService implements SubmitService {

  @Override
  public DelfiIngestedFile getIngestedFile(SubmittedFile file, JobStatusResponse response,
      RequestContext requestContext) {
    String location = GCS_PROTOCOL + response.getSummary().getOutputLocation()
        + SUCCESS_METADATA_JSON_PATH;
    log.debug("File location of ingestion job success metadata: {}", location);
    DelfiFile delfiFile = portalService.getFile(location, requestContext.getAuthorizationToken(),
        requestContext.getPartition());
    String fileContent = restTemplate.getForObject(delfiFile.getSignedUrl(), String.class);
    log.debug("Success metadata: {}", fileContent);
    SuccessMetadata metadata = toObject(fileContent, SuccessMetadata.class);
    SaveRecordsResult saveResult = toObject(metadata.getMessage(), SaveRecordsResult.class);
    log.debug("Save records result: {}", saveResult);

    return DelfiIngestedFile.builder()
        .submittedFile(file)
        .recordId(saveResult.getRecordIds().get(0))
        .build();
  }

}