build_vec_url: Functions to build the url required to call the API

View source: R/fetch_vectronics.R

build_vec_urlR Documentation

Functions to build the url required to call the API

Description

The url is composed of a base that never changes, a collar id, a collar key data type and either a start id or date at a minimum. These pieces must be put together in a rather particular order with appropriate punctuation. This is the role of these functions.

Usage

build_vec_url(
  base_url = NULL,
  collar_id = NULL,
  collar_key = NULL,
  type = c("gps", "act", "mit", "mor", "prx", "sep", "trap", "vit"),
  count = FALSE,
  after_data_id = NULL,
  start_date = NULL,
  which_date = NULL
)

build_vec_urls(
  base_url = NULL,
  collar_id = NULL,
  collar_key = NULL,
  type = c("gps", "act", "mit", "mor", "prx", "sep", "trap", "vit"),
  count = FALSE,
  after_data_id = NULL,
  start_date = NULL,
  which_date = c("scts", "acquisition")
)

Arguments

base_url

NULL or the url to build from, the default NULL should suffice in almost all cases

collar_id

The ID(s) of the collars to query for data

collar_key

The key(s) of the collars to query for data

type

The data type, options include "gps", "act", "mit", "mor", "prx", "sep", "trap" and "vit". See details.

count

logical indicating whether you want a count of the data type

after_data_id

All data types have a unique ID maintained by the manufacturer. Use this parameter to download data after the supplied data ID. Must be equal in length to collar_id and collar_key. Only one of start_date and after_data_id may be supplied.

start_date

A character vector specifying date and time as DD-MM-YYYYTHH:MM:SS (the T is required, for example 01-01-2018T00:00:00). Supplying this parameter will cause the API to only return data collected after the supplied date. Must be equal in length to collar_id and collar_key. Only one of start_date and after_data_id may be supplied.

which_date

either scts or acquisition, indicates date column to use for subsetting

Details

The functions build_vec_url and build_vec_urls differ only in that build_vec_url builds a single url from a collection of length 1 arguments while build_vec_urls will function on vectors of inputs to create numerous urls. Functionally the user is encouraged to only use the plural version so that code will function regardles of the length of the input.

Data types are defined by the user and only a single data type is returned by the API for any given call. The url tells the API which data type to return, such that passing

  • "count" modifies requests below to return count of data type

  • "gps" returns location data

  • "act" returns activity data

  • "mit" returns implant mortality data

  • "mor" returns mortality data

  • "prx" returns proximity data

  • "sep" returns separation data

  • "trap" returns trap event data

  • "vit" returns vaginal implant data

Value

Formatted url(s) as a character string


Huh/collar documentation built on Aug. 5, 2022, 11:02 p.m.