Manual Reference Source Test
import IHttpService from 'pop-api-scraper/src/http/IHttpService.js'
public interface | source

IHttpService

Direct Subclass:

AbstractHttpService

Indirect Subclass:

HttpService

Direct Implemented:

Indirect Implemented:

Interface to send HTTP requests.

Test:

Method Summary

Public Methods
public

delete(endpoint: string, opts: Object): Promise<Object, Error>

Make a DELETE request.

public

download(endpoint: string, filePath: string): Promise<string, Error>

Request to download an item.

public

get(endpoint: string, opts: Object, raw: boolean): Promise<Object, Error>

Make a GET request.

public

post(endpoint: string, opts: Object): Promise<Object, Error>

Make a POST request.

public

printDebug(method: string, uri: string, opts: Object): undefined

Print the debug message.

public

put(endpoint: string, opts: Object): Promise<Object, Error>

Make a PUT request.

public

request(method: string, endpoint: string, opts: Object, raw: boolean): Promise<Object, Error>

Make a HTTP request.

Public Methods

public delete(endpoint: string, opts: Object): Promise<Object, Error> source

Make a DELETE request.

Params:

NameTypeAttributeDescription
endpoint string
  • optional
  • nullable: false

The endpoint to make the DELETE request to.

opts Object
  • optional
  • default: {}
  • nullable: true

The options for the HTTP DELETE request.

Return:

Promise<Object, Error>

Promise with the HTML loaded in cheerio.

Throw:

Error

Using default method: 'delete'

Test:

public download(endpoint: string, filePath: string): Promise<string, Error> source

Request to download an item.

Params:

NameTypeAttributeDescription
endpoint string
  • nullable: false

The uri to the item.

filePath string
  • nullable: false

The name of the file to save the item.

Return:

Promise<string, Error>

Message when it's finally downloaded.

Throw:

Error

Using default method: 'download'

Test:

public get(endpoint: string, opts: Object, raw: boolean): Promise<Object, Error> source

Make a GET request.

Params:

NameTypeAttributeDescription
endpoint string
  • optional
  • nullable: false

The endpoint to make the GET request to.

opts Object
  • optional
  • default: {}
  • nullable: true

The options for the HTTP GET request.

raw boolean
  • optional
  • default: false
  • nullable: true

Return json object.

Return:

Promise<Object, Error>

Promise with the HTML loaded in cheerio.

Throw:

Error

Using default method: 'get'

Test:

public post(endpoint: string, opts: Object): Promise<Object, Error> source

Make a POST request.

Params:

NameTypeAttributeDescription
endpoint string
  • optional
  • nullable: false

The endpoint to make the POST request to.

opts Object
  • optional
  • default: {}
  • nullable: true

The options for the HTTP POST request.

Return:

Promise<Object, Error>

Promise with the HTML loaded in cheerio.

Throw:

Error

Using default method: 'post'

Test:

public printDebug(method: string, uri: string, opts: Object): undefined source

Print the debug message.

Params:

NameTypeAttributeDescription
method string
  • nullable: false

The method of the HTTP request.

uri string
  • nullable: false

The uri of the HTTP request.

opts Object
  • default: this._opts
  • nullable: true

The options for the HTTP request.

Return:

undefined

Throw:

Error

Using default method: 'printDebug'

Test:

public put(endpoint: string, opts: Object): Promise<Object, Error> source

Make a PUT request.

Params:

NameTypeAttributeDescription
endpoint string
  • optional
  • nullable: false

The endpoint to make the PUT request to.

opts Object
  • optional
  • default: {}
  • nullable: true

The options for the HTTP PUT request.

Return:

Promise<Object, Error>

Promise with the HTML loaded in cheerio.

Throw:

Error

Using default method: 'put'

Test:

public request(method: string, endpoint: string, opts: Object, raw: boolean): Promise<Object, Error> source

Make a HTTP request.

Params:

NameTypeAttributeDescription
method string
  • nullable: false

The method of the HTTP request.

endpoint string
  • optional
  • nullable: false

The endpoint to make the HTTP request to.

opts Object
  • optional
  • nullable: true

The options for the HTTP request.

raw boolean
  • optional
  • nullable: true

Return the raw body.

Return:

Promise<Object, Error>

Promise with the HTML loaded in cheerio.

Throw:

Error

Using default method: 'request'

Test: