An R6 class that wraps an api_client and adds an additional path segment
(like "beta" or "v1.0") to all requests. This is useful for APIs that version
their endpoints or have different API surfaces under different paths.
Details
The api_resource class creates a modified base request by appending an
endpoint path to the client's base request. All subsequent API calls through
this resource will automatically include this path prefix.
Methods
Method new()
Create a new API resource instance
Usage
api_resource$new(client, endpoint)Examples
if (FALSE) { # \dontrun{
# Create a client
client <- api_client$new(
host_url = "https://graph.microsoft.com"
)
# Create a resource with v1.0 API endpoint
resource_v1 <- api_resource$new(
client = client,
endpoint = "v1.0"
)
# Create a resource with beta API endpoint
resource_beta <- api_resource$new(
client = client,
endpoint = "beta"
)
# Make requests - the endpoint is automatically prepended
response <- resource_v1$.fetch(
path = "/me",
req_method = "get"
)
} # }