-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathrequest_generate.Rd
73 lines (68 loc) · 3.02 KB
/
request_generate.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/request_generate.R
\name{request_generate}
\alias{request_generate}
\title{Generate a Google Sheets API request}
\usage{
request_generate(
endpoint = character(),
params = list(),
key = NULL,
token = gs4_token()
)
}
\arguments{
\item{endpoint}{Character. Nickname for one of the selected Sheets API v4
endpoints built into googlesheets4. Learn more in \code{\link[=gs4_endpoints]{gs4_endpoints()}}.}
\item{params}{Named list. Parameters destined for endpoint URL substitution,
the query, or the body.}
\item{key}{API key. Needed for requests that don't contain a token. The need
for an API key in the absence of a token is explained in Google's document
"Credentials, access, security, and identity"
(\verb{https://support.google.com/googleapi/answer/6158857?hl=en&ref_topic=7013279}).
In order of precedence, these sources are consulted: the formal \code{key}
argument, a \code{key} parameter in \code{params}, a user-configured API key set up
with \code{\link[=gs4_auth_configure]{gs4_auth_configure()}} and retrieved with \code{\link[=gs4_api_key]{gs4_api_key()}}.}
\item{token}{Set this to \code{NULL} to suppress the inclusion of a token. Note
that, if auth has been de-activated via \code{\link[=gs4_deauth]{gs4_deauth()}},
\code{gs4_token()} will actually return \code{NULL}.}
}
\value{
\code{list()}\cr Components are \code{method}, \code{url}, \code{body}, and \code{token},
suitable as input for \code{\link[=request_make]{request_make()}}.
}
\description{
Generate a request, using knowledge of the \href{https://developers.google.com/sheets/api/}{Sheets API} from its Discovery
Document (\verb{https://www.googleapis.com/discovery/v1/apis/sheets/v4/rest}). Use
\code{\link[=request_make]{request_make()}} to execute the request. Most users should, instead, use
higher-level wrappers that facilitate common tasks, such as reading or
writing worksheets or cell ranges. The functions here are intended for
internal use and for programming around the Sheets API.
\code{request_generate()} lets you provide the bare minimum of input.
It takes a nickname for an endpoint and:
\itemize{
\item Uses the API spec to look up the \code{method}, \code{path}, and \code{base_url}.
\item Checks \code{params} for validity and completeness with respect to the
endpoint. Uses \code{params} for URL endpoint substitution and separates
remaining parameters into those destined for the body versus the query.
\item Adds an API key to the query if and only if \code{token = NULL}.
}
}
\examples{
req <- request_generate(
"sheets.spreadsheets.get",
list(spreadsheetId = gs4_example("deaths")),
key = "PRETEND_I_AM_AN_API_KEY",
token = NULL
)
req
}
\seealso{
\code{\link[gargle:request_develop]{gargle::request_develop()}}, \code{\link[gargle:request_develop]{gargle::request_build()}},
\code{\link[gargle:request_make]{gargle::request_make()}}
Other low-level API functions:
\code{\link{gs4_has_token}()},
\code{\link{gs4_token}()},
\code{\link{request_make}()}
}
\concept{low-level API functions}