| api_resource | R Documentation |
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.
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.
.clientThe cloned api_client instance with modified base_req
new()Create a new API resource instance
api_resource$new(client, endpoint)
clientAn api_client object that provides the base HTTP client
functionality. This will be cloned to avoid modifying the original.
endpointA character string specifying the API endpoint or path
segment to append (e.g., "v1.0", "beta").
A new api_resource object
clone()The objects of this class are cloneable with this method.
api_resource$clone(deep = FALSE)
deepWhether to make a deep clone.
## Not run:
# 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",
method = "get"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.