Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yamadapc/toggl-events

Higher-level wrapper on top of the Toggl WebSockets API.
https://github.com/yamadapc/toggl-events

Last synced: 15 days ago
JSON representation

Higher-level wrapper on top of the Toggl WebSockets API.

Awesome Lists containing this project

README

        

toggl-events
============
Higher-level wrapper on top of the Toggl WebSockets API.

## Usage
```javascript
var TogglEvents = require('toggl-events');
TogglEvents.onMessage(function(message) {
console.log(message);
}, process.env.TOGGL_API_TOKEN):
```

## API Documentation
### `new TogglEvents(options)`
Creates a WebSocket connection with Toggl and starts emitting events.

- `[options.token]` **(String)** - An API token
- - -
- `[options.url]` **(String)** - The Toggl WebSocket URL to hit
- `[options.origin]` **(String)** - The origin to use

### Events emitted by `TogglEvents`
`TogglEvents` is an `EventEmitter`. It emits:
- **close**
- **connect**
- **open**

### `TogglEvents.prototype.connect([options])`
Forces a re-connection with an optional new hash of options. Won't overwrite the
options property and will be merged with the hash passed into the constructor

### `TogglEvents.prototype.authenticate([token])`
Forces re-authentication with an optional new token.

### `TogglEvents.prototype.send([msg])`
Sends an object as a message through the connection.

### `TogglEvents.prototype.isConnected()`
Returns true if the connection is open.

### `TogglEvents.prototype.isAuthenticated()`
Returns true if the connection is authenticated.

### `TogglEvents.onMessage(callback[, options][, token])`
Helper to create quick message listeners.

## License
This code is licensed under the MIT license.

## Donations
Would you like to buy me a beer? Send bitcoin to 3JjxJydvoJjTrhLL86LGMc8cNB16pTAF3y