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

Description Usage Arguments Details Value Examples

View source: R/build_urls.R

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

1
2
3
4
5
6
7
cdr_build_vec_url(base_url = NULL, collar_id = NULL,
  collar_key = NULL, type = c("gps", "act", "mit", "mor", "prx", "SEP",
  "TRAP"), after_data_id = NULL, start_date = NULL)

cdr_build_vec_urls(base_url = NULL, collar_id = NULL,
  collar_key = NULL, type = c("gps", "act", "mit", "mor", "prx", "SEP",
  "TRAP"), after_data_id = NULL, start_date = NULL)

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" and "TRAP". See details.

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, but one of the two must 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, but one must be supplied.

Details

The functions cdr_build_vec_url and cdr_build_vec_urls differ only in that cdr_build_vec_url builds a single url from a collection of length 1 arguments while cdr_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

Value

Formatted url(s) as a character string

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
cdr_build_vec_urls(
  base_url = NULL,
  collar_id = cdr_get_id_from_key(
    system.file("extdata", package = "CollarDownloadeR")
  ),
  collar_key = cdr_get_keys(
    system.file(
      "extdata",
      package = "CollarDownloadeR"
    )
  ),
  type = "act"
)

Huh/CollarDownloadeR documentation built on May 27, 2019, 11:47 p.m.