BiodbRequest {biodb} | R Documentation

## Class Request.

### Description

Class Request.

Class Request.

### Details

This class represents a Request object that can be used with the Request Scheduler.

### Methods

#### Public methods

- `BiodbRequest$new()`

- `BiodbRequest$setConn()`

- `BiodbRequest$getConn()`

- `BiodbRequest$getUrl()`

- `BiodbRequest$getMethod()`

- `BiodbRequest$getEncoding()`

- `BiodbRequest$getCurlOptions()`

- `BiodbRequest$getUniqueKey()`

- `BiodbRequest$getHeaderAsSingleString()`

- `BiodbRequest$getBody()`

- `BiodbRequest$print()`

- `BiodbRequest$toString()`

- `BiodbRequest$clone()`

#### Method `new()`

Constructor.

##### Usage

    BiodbRequest$new(
      url,
      method = c("get", "post"),
      header = character(),
      body = character(),
      encoding = integer(),
      conn = NULL
    )

##### Arguments

`url`

  A `BiodbUrl` object.

`method`

  HTTP method. Either "get" or "post".

`header`

  The header.

`body`

  The body.

`encoding`

  The encoding to use.

`conn`

  A valid BiodbConn instance for which this request is built.

##### Returns

A new instance.

#### Method `setConn()`

Sets the associated connector (usually the connector that created this request).

##### Usage

    BiodbRequest$setConn(conn)

##### Arguments

`conn`

  A valid BiodbConn object.

##### Returns

None.

#### Method `getConn()`

gets the associated connector (usually the connector that created this request).

##### Usage

    BiodbRequest$getConn()

##### Returns

The associated connector as a BiodbConn object.

#### Method `getUrl()`

Gets the URL.

##### Usage

    BiodbRequest$getUrl()

##### Returns

The URL as a BiodbUrl object.

#### Method `getMethod()`

Gets the method.

##### Usage

    BiodbRequest$getMethod()

##### Returns

The method as a character value.

#### Method `getEncoding()`

Gets the encoding.

##### Usage

    BiodbRequest$getEncoding()

##### Returns

The encoding.

#### Method `getCurlOptions()`

Gets the options object to pass to cURL library.

##### Usage

    BiodbRequest$getCurlOptions(useragent)

##### Arguments

`useragent`

  The user agent as a character value.

##### Returns

An RCurl options object.

#### Method `getUniqueKey()`

Gets a unique key to identify this request. The key is an MD5 sum computed from the string representation of this request.

##### Usage

    BiodbRequest$getUniqueKey()

##### Returns

A unique key as an MD5 sum.

#### Method `getHeaderAsSingleString()`

Gets the HTTP header as a string, concatenating all its information into a single string.

##### Usage

    BiodbRequest$getHeaderAsSingleString()

##### Returns

The header as a single character value.

#### Method `getBody()`

Gets the body.

##### Usage

    BiodbRequest$getBody()

##### Returns

The body as a character value.

#### Method `print()`

Displays information about this instance.

##### Usage

    BiodbRequest$print()

##### Returns

None.

#### Method `toString()`

Gets a string representation of this instance.

##### Usage

    BiodbRequest$toString()

##### Returns

A single string giving a representation of this instance.

#### Method `clone()`

The objects of this class are cloneable with this method.

##### Usage

    BiodbRequest$clone(deep = FALSE)

##### Arguments

`deep`

  Whether to make a deep clone.

### See Also

`BiodbRequestScheduler`, `BiodbUrl`.

### Examples

    # Create an instance with default settings:
    mybiodb <- biodb::newInst()

    # Create a request object
    u <- 'https://www.ebi.ac.uk/webservices/chebi/2.0/test/getCompleteEntity'
    url <- BiodbUrl$new(url=u)
    url$setParam('chebiId', 15440)
    request <- BiodbRequest$new(method='get', url=url)

    # Send request
    mybiodb$getRequestScheduler()$sendRequest(request)

    # Terminate instance.
    mybiodb$terminate()

[Package biodb version 1.0.4 Index]