Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/yamadapc/toggl-events
- Owner: yamadapc
- License: mit
- Created: 2015-10-16T15:33:35.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-02T17:53:41.000Z (almost 9 years ago)
- Last Synced: 2024-12-24T11:58:05.509Z (17 days ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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