R/track_progress.R

Defines functions track_progress

Documented in track_progress

#' Track Progress of a Job
#' 
#' Check what percentage of the job is digitized
#' 
#' @param job_id ID for the job (which you get from related_job_id field of submit_batch)
#' 
#' @export
#' 
#' @references \url{https://shreddr.captricity.com/developer/}
#' 
#' @examples \dontrun{
#' track_progress("job_id")
#' }

track_progress <- function(job_id = "") {

  captr_CHECKAUTH()

  if ( is.null(job_id) | identical(job_id, "")) stop("Provide a Valid Job ID.")

  h <- new_handle()
  handle_setopt(h,  customrequest = "GET")
  handle_setheaders(h, "Captricity-API-Token" = Sys.getenv("CaptricityToken"))

  target_url <- paste0("https://shreddr.captricity.com/api/v1/job/", job_id)
  tag_con  <- curl_fetch_memory(target_url, handle = h)
  tag    <- fromJSON(rawToChar(tag_con$content))

  tag
}
soodoku/captR documentation built on May 30, 2019, 6:27 a.m.