download_item {trud}R Documentation

Download NHS TRUD item

Description

Downloads files for a specified NHS TRUD item (requires a subscription). By default this is the latest release.

Usage

download_item(
  item,
  directory = ".",
  download_file = "archive",
  TRUD_API_KEY = NULL,
  release = NULL
)

Arguments

item

An integer, the item to be downloaded.

directory

Path to the directory to which this item will be downloaded to. This is set to the current working directory by default.

download_file

The item file to be downloaded. Valid values:

  • "archive" (the release item)

  • "checksum"

  • "signature"

  • "publickKey"

TRUD_API_KEY

A string. The name of an environmental variable containing your TRUD API key. If NULL (default) this is assumed to be called TRUD_API_KEY.

release

The name of a specific release ID to be downloaded (this can be ascertained using get_item_metadata()). If NULL (default), then the latest item release will be downloaded.

Value

The file path to the downloaded file, returned invisibly.

Examples

## Not run: 
 # Download Community Services Data Set pre-deadline extract XML Schema
 x <- download_item(394, directory = tempdir())

 # List downloaded files
 unzip(x, list = TRUE)

 # Download a previous release
 release <- get_item_metadata(394)$releases[[2]]$id

 y <- download_item(394, directory = tempdir(), release = release)

 unzip(y, list = TRUE)

## End(Not run)

# An informative error is raised if your API key is invalid or missing
try(download_item(394, TRUD_API_KEY = "INVALID_API_KEY"))

[Package trud version 0.1.0 Index]