| Collection {sevenbridges2} | R Documentation |
R6 Class representing a Collection of objects
Description
R6 Class representing a resource for managing collections. Wrapper for Seven Bridges pageable resources. Among the actual collection items it contains information regarding the total number of entries available on the server and resource API request URL (href).
Public fields
hrefAPI request URL.
itemsItems returned in API response.
linksList of links (hrefs) for next and/or previous page resources.
totalTotal number of items available on the server.
responseRaw API response.
authSeven Bridges Authentication object.
Methods
Public methods
Method new()
Create a new Collection object.
Usage
Collection$new( href = NA, items = NA, links = NA, total = NA, response = NA, auth = NA )
Arguments
hrefAPI request URL.
itemsItems returned in API response.
linksList of links (hrefs) for next and/or previous page resources.
totalTotal number of items available on the server.
responseRaw API response.
authSeven Bridges Authentication object.
Method print()
Print method for Collection class.
Usage
Collection$print(n = 10)
Arguments
nNumber of items to print in console.
Examples
\dontrun{
# x is API response when collection object is requested
collection_object <- Collection$new(
href = x$href,
items = x$items,
links = x$links,
total = x$total,
auth = auth,
response = attr(x, "response")
)
# Print collection object
collection_object$print()
}
Method next_page()
Return next page of results.
Usage
Collection$next_page(...)
Arguments
...Other arguments that can be passed to core
api()function like 'advanced_access', 'fields', etc.
Examples
\dontrun{
# x is API response when collection object is requested
collection_object <- Collection$new(
href = x$href,
items = x$items,
links = x$links,
total = x$total,
auth = auth,
response = attr(x, "response")
)
# Get next page of collection results
collection_object$next_page()
}
Method prev_page()
Return previous page of results.
Usage
Collection$prev_page(...)
Arguments
...Other arguments that can be passed to core
api()function like 'advanced_access', 'fields', etc.
Examples
\dontrun{
# x is API response when collection object is requested
collection_object <- Collection$new(
href = x$href,
items = x$items,
links = x$links,
total = x$total,
auth = auth,
response = attr(x, "response")
)
# Get previous page of collection results
collection_object$prev_page()
}
Method all()
Fetches all available items by iterating through all pages. Please be aware of the API rate limit for your request.
Usage
Collection$all(...)
Arguments
...Other arguments that can be passed to core
api()function like 'advanced_access', 'fields', etc.
Examples
\dontrun{
# x is API response when collection object is requested
collection_object <- Collection$new(
href = x$href,
items = x$items,
links = x$links,
total = x$total,
auth = auth,
response = attr(x, "response")
)
# Get all results of collection
collection_object$all()
}
Method clone()
The objects of this class are cloneable with this method.
Usage
Collection$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
## ------------------------------------------------
## Method `Collection$print`
## ------------------------------------------------
## Not run:
# x is API response when collection object is requested
collection_object <- Collection$new(
href = x$href,
items = x$items,
links = x$links,
total = x$total,
auth = auth,
response = attr(x, "response")
)
# Print collection object
collection_object$print()
## End(Not run)
## ------------------------------------------------
## Method `Collection$next_page`
## ------------------------------------------------
## Not run:
# x is API response when collection object is requested
collection_object <- Collection$new(
href = x$href,
items = x$items,
links = x$links,
total = x$total,
auth = auth,
response = attr(x, "response")
)
# Get next page of collection results
collection_object$next_page()
## End(Not run)
## ------------------------------------------------
## Method `Collection$prev_page`
## ------------------------------------------------
## Not run:
# x is API response when collection object is requested
collection_object <- Collection$new(
href = x$href,
items = x$items,
links = x$links,
total = x$total,
auth = auth,
response = attr(x, "response")
)
# Get previous page of collection results
collection_object$prev_page()
## End(Not run)
## ------------------------------------------------
## Method `Collection$all`
## ------------------------------------------------
## Not run:
# x is API response when collection object is requested
collection_object <- Collection$new(
href = x$href,
items = x$items,
links = x$links,
total = x$total,
auth = auth,
response = attr(x, "response")
)
# Get all results of collection
collection_object$all()
## End(Not run)