imMail Web API
The @immail/web-api
lib contains an easy and customizable HTTP client for using Web API or on-premise versions.
Use it in your app to call any of the endpoints.
Installation
$ npm install @immail/web-api
Usage
These example shows one of the most common features of the WebClient
.
Initialize the client
The package exports a WebClient
class. All you need to do is instantiate it, and you're ready to go. You'll typically
initialize it with a { host }
. If you do not provide a host, the default one (https://api.immail.ca) will be defined.
const { WebClient } = require('@immail/web-api');
// Read a host, login and password from the environment variables
const host = process.env.IMMAIL_API_HOST // Optional. Usefull for on-premise versions. The imMail's production host will be set as default
const login = process.env.IMMAIL_LOGIN
const password = process.env.IMMAIL_PASSWORD
// Initialize
const webImmail = new WebClient({ host })
// Login
await webImmail.login({ login, password })