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

href

API request URL.

items

Items returned in API response.

links

List of links (hrefs) for next and/or previous page resources.

total

Total number of items available on the server.

response

Raw API response.

auth

Seven 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
href

API request URL.

items

Items returned in API response.

links

List of links (hrefs) for next and/or previous page resources.

total

Total number of items available on the server.

response

Raw API response.

auth

Seven Bridges Authentication object.


Method print()

Print method for Collection class.

Usage
Collection$print(n = 10)
Arguments
n

Number 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
deep

Whether 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)


[Package sevenbridges2 version 0.2.0 Index]