dot-AddHTTPArgs: Add GET parameters to a URL string.

Description Usage Arguments Value Examples

Description

.AddHTTPArgs is an internal function. It takes a named list and creates a GET parameter string suitable for inclusion in a URL. It adds a question mark ('?') to the beginning of the string and separates each name-value pair with an ampersand ('&'). List items with NULL values are ignored.

Usage

1
.AddHTTPArgs(url, http_args)

Arguments

url

A character vector containing the portion of the FIRST API URL that follows the season parameter and forward slash, but is not a GET parameter (i.e., before the '?'). For most FIRST API commands, the url string will be the simple string that identifies the command, e.g., "districts" or "teams". A few FIRST API commands use path parameters (i.e., Detailed Scores) in addition to GET parameters – in such cases the url argument must contain the path parameters separated by '/'.

http_args

A list of all GET parameters that will be supplied to the URL query string. The elements of the list must have a name that that matches the name of the GET parameter (e.g., teamNumber, eventCode). Any list elements that are NULL will be skipped.

Value

A character vector containing the portion of the FIRST API URL starting with the path parameter that immediately follows the season (not including the '/') and extending to the end of the URL, including the GET query string.

Examples

1
2
3
4
5
6
7
8
  # From GetTeams()
  team_args <- list(teamNumber = team, eventCode = event,
    districtCode = district, state = state, page = page)
 url <- .AddHTTPArgs("teams", team_args)

 # From GetRankings()
 rank_args <- list(teamNumber = team, top = top)
 url <- .AddHTTPArgs(paste("rankings", event, sep = "/"), rank_args)

irwinsnet/FIRST_api_R documentation built on Dec. 22, 2020, 5:12 p.m.