HTTPInteractionList {vcr} | R Documentation |
HTTPInteractionList class
Description
keeps track of all HTTPInteraction objects
Details
Private Methods
has_unused_interactions()
-
Are there any unused interactions? returns boolean
matching_interaction_index_for()
-
asdfadf
matching_used_interaction_for(request)
-
asdfadfs
interaction_matches_request(request, interaction)
-
Check if a request matches an interaction (logical)
from_hash()
-
Get a hash back.
request_summary(z)
-
Get a request summary (character)
response_summary(z)
-
Get a response summary (character)
Public fields
interactions
(list) list of interaction class objects
request_matchers
(character) vector of request matchers
allow_playback_repeats
whether to allow playback repeats
parent_list
A list for empty objects, see
NullList
used_interactions
(list) Interactions that have been used
Methods
Public methods
Method new()
Create a new HTTPInteractionList
object
Usage
HTTPInteractionList$new( interactions, request_matchers, allow_playback_repeats = FALSE, parent_list = NullList$new(), used_interactions = list() )
Arguments
interactions
(list) list of interaction class objects
request_matchers
(character) vector of request matchers
allow_playback_repeats
whether to allow playback repeats or not
parent_list
A list for empty objects, see
NullList
used_interactions
(list) Interactions that have been used. That is, interactions that are on disk in the current cassette, and a request has been made that matches that interaction
Returns
A new HTTPInteractionList
object
Method response_for()
Check if there's a matching interaction, returns a response object
Usage
HTTPInteractionList$response_for(request)
Arguments
request
The request from an object of class
HTTPInteraction
Method has_interaction_matching()
Check if has a matching interaction
Usage
HTTPInteractionList$has_interaction_matching(request)
Arguments
request
The request from an object of class
HTTPInteraction
Returns
logical
Method has_used_interaction_matching()
check if has used interactions matching a given request
Usage
HTTPInteractionList$has_used_interaction_matching(request)
Arguments
request
The request from an object of class
HTTPInteraction
Returns
logical
Method remaining_unused_interaction_count()
Number of unused interactions
Usage
HTTPInteractionList$remaining_unused_interaction_count()
Returns
integer
Method assert_no_unused_interactions()
Checks if there are no unused interactions left.
Usage
HTTPInteractionList$assert_no_unused_interactions()
Returns
various
Method clone()
The objects of this class are cloneable with this method.
Usage
HTTPInteractionList$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## Not run:
vcr_configure(
dir = tempdir(),
record = "once"
)
# make interactions
## make the request
### turn off mocking
crul::mock(FALSE)
url <- "https://hb.opencpu.org/post"
cli <- crul::HttpClient$new(url = url)
res <- cli$post(body = list(a = 5))
## request
(request <- Request$new("POST", url, list(a = 5), res$headers))
## response
(response <- VcrResponse$new(
res$status_http(),
res$response_headers,
res$parse("UTF-8"),
res$response_headers$status))
## make an interaction
(inter <- HTTPInteraction$new(request = request, response = response))
# make an interactionlist
(x <- HTTPInteractionList$new(
interactions = list(inter),
request_matchers = vcr_configuration()$match_requests_on
))
x$interactions
x$request_matchers
x$parent_list
x$parent_list$response_for()
x$parent_list$has_interaction_matching()
x$parent_list$has_used_interaction_matching()
x$parent_list$remaining_unused_interaction_count()
x$used_interactions
x$allow_playback_repeats
x$interactions
x$response_for(request)
## End(Not run)