npm package: @plasma-platform/tm-centrifuge
Description: Class to work with centrifuge
Author: Anton Nemtsev
Latest version: 0.5.0

# TM Micro Service API Prototype class

This class provide fetch wrapper, token and Service URL setter mainly. Just to avoid code duplication.

## Requirements

Possibly you will need babel-polyfill to use it.

# Documentation

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

## ErrorBadRequest

**Extends Error**

Custom error message for Bad Request server response

**Parameters**

-   `message` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** error details (optional, default `null`)

### constructor

Constructor generates errorinstance

**Parameters**

-   `message` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** error details (optional, default `null`)

Returns **[ErrorBadRequest](#errorbadrequest)** current instance

## ErrorCentrifuge

**Extends Error**

Custom error message for abstract server response

**Parameters**

-   `statusCode` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** http status code
-   `statusText` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** http status code text
-   `message` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** error details (optional, default `null`)

### constructor

Constructor generates error instance

**Parameters**

-   `statusCode` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** http status code
-   `statusText` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** http status code text
-   `message` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** error details (optional, default `null`)

Returns **[ErrorCentrifuge](#errorcentrifuge)** current instance

## ErrorServerResponse

**Extends Error**

Custom error message for abstract server response

**Parameters**

-   `statusCode` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** http status code
-   `statusText` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** http status code text
-   `message` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** error details (optional, default `null`)

### constructor

Constructor generates error instance

**Parameters**

-   `statusCode` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** http status code
-   `statusText` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** http status code text
-   `message` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** error details (optional, default `null`)

Returns **[ErrorServerResponse](#errorserverresponse)** current instance

## TMCentrifuge

TM Interface to Centrifuge

**Parameters**

-   `options`  
-   `url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** service url

## constructor

Constructor saves service url

**Parameters**

-   `options` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** centrifuge options
    -   `options.url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** centrifuge url
    -   `options.timestamp` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** timestamp to sync instances in seconds,
        you set it up before get centrifuge token
    -   `options.token` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** centrifuge token from backend
    -   `options.user` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** may contain different values — user or card id, for example

Returns **[TMCentrifuge](#tmcentrifuge)** centrifuge instance