add_parameter: Suffix a parameter to a HTML request

Description Usage Arguments Details Value Examples

View source: R/url-manipulation.R

Description

Parameters are suffixed to a URL, like so: "request?para1=value1&para2=value2". The first parameter is suffixed with "?" and all others after that "&". This function will determine the correct suffix based on the presence of "&" in the request.

Usage

1
2
3
4
5
6
add_parameter(
  request,
  parameter_name,
  parameter_value,
  .combine = "repeat_name"
)

Arguments

request

Character. The base URL or request which will be suffixed with the parameter.

parameter_name

Character. Name of parameter to suffix.

parameter_value

Character, or a value that can be coerced to a character. The value of the parameter to suffix.

.combine

How to combine parameters with multiple values. One of "repeat_name", "with_commas", "with_hex_commas". See Details.

Details

There is no standardised way to combine multiple values for a parameter. You should see how your API expects multiple values to be provided to the same parameter. This function allows for the following strategies. If any other value is provided, then the values will be concatenated and separated with the provided value.

Value

Character. The request with suffixed parameters.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
ptvapi:::add_parameter("www.example.com", "animal", "crocodile")
ptvapi:::add_parameter(
  "www.example.com",
  "numbers",
  c(1, 2, 3),
  .combine = "repeat_names"
)
## End(Not run)

ptvapi documentation built on May 2, 2021, 9:06 a.m.