GetSession: Create a firstapiR session

Description Usage Arguments Details Value Examples

View source: R/firstapiR_main.R

Description

Every firstapiR function requires a Session object as its first parameter.

Usage

1
2
3
4
5
6
7
GetSession(
  username,
  key,
  season = .default_season,
  format = "data.frame",
  staging = FALSE
)

Arguments

username

A character vector containing the username assigned by FIRST.

key

A character vector containing the authorization key assigned by FIRST, or the value "key".

season

An integer vector containing the 4-digit year. Must be equal to or less than the current season and greater than or equal to 2015. Optional: defaults to the current year.

format

A character vector that specifies the data format that will be returned by firstapiR functions. Can be "json", "data.frame", or "xml" (case insensitive). Optional: defaults to "data.frame".

staging

A logical vector. If set to TRUE, firstapiR uses the staging URL. Optional: defaults to FALSE.

Details

The Session object is an R list that contains the FIRST API username and authorization key, season, format, and a boolean value that specifies whether to use the staging server instead of the production server.

The key argument may be set to the value "key". If this is done, the firstapiR functions will skip the HTTP request and will extract example data from the R/sysdata.rda file, which is included with the firstapiR package. This function is for testing and demonstrations when no internet connection or valid authorization key is available. Example data frames returned by firstapiR functions will have their local_test_data attribute set to TRUE and the time_downloaded attribute will be set to the date and time that the example data was downloaded from the server and stored in the R/sysdata.rda file.

Throws an error if season, format, or staging arguments are incorrect.

Value

A Session object containing all GetSession parameters. The class attribute is set to c("list", "Session")

Examples

1
2
3
sn <- GetSession("myUserName", "myAuthorizationKey")
sn <- GetSession("myUserName", "myAuthorizationKey", season = 2015)
sn$format <- "xml"

irwinsnet/firstapiR documentation built on Dec. 22, 2020, 5:13 p.m.