gopherhq
v0.0.22-beta
Published
Gopher Email API client for the browser and node.js
Readme
Gopher API JS Client (Preview)
JavaScript client for interacting with the Gopher Email API. Works in the browser and node.js.
Note: Gopher is currently in private beta. Enter your email on the Gopher Home Page to request an invitation
Usage
Quick example:
npm install gopherhqconst var Gopher = require('gopherhq');
// initialize
const gopherClient = new Gopher({clientId: 'YOUR_EXTENSIONS_CLIENT_ID'});
gopherClient.setAccessToken('YOUR_OAUTH2_ACCESS_TOKEN');
// create a task
const task = {
task: {
reference_email: {
server_recipient: '[email protected]',
to: ['[email protected]'],
subject: "Test1",
html: "Test1",
}
}
}
// create a task with a callback
gopherClient.createTask(task, function(err, res) { console.log(err || res)});
// promises work, too.
const res = gopherClient.createTask(task)
.then(function(res) {
console.log(res);
})
.catch(function(err) {
console.log(err);
});
// along with async/await magic, of course ✨
const res = await gopherClient.createTask(task); //in async functionYOUR_EXTENSIONS_CLIENT_ID– Find this in the developer portal.YOUR_OAUTH2_ACCESS_TOKEN- Log in to your extension and copy the value from thegopherTokencookie using something like EditThisCookie or the Chrome dev tools.
Examples
- See the
testdirectory for usage examples. - gopher-express, an open source Gopher Extension
- Create a new extension and remix Gopher Express on Glitch to start prototyping right away.
Debugging
Set the env variable DEBUG=gopherhq to log debugging information.
Contributions
Contributions are welcome. Feel free to send us an email [email protected] or create a PR. A few notes:
npm twill watch for changes and re-run tests on save, letting you make rapid progress.- See comment in
gopherTestUtils.jsabout mocking network requests. - Make sure to run
npm run buildto rebuild the lib.
License
MIT
