@payhos/api
v2.1.0
Published
An API package for payhos's API built for JavaScript and Typescript developers
Downloads
22
Readme
PayHos API SDK
PayHos is an easy go-to solution for many day-to-day application problems by providing an easily access to send emails, SMS etc. For a full documentations of PayHos API and fully supported features, visit PayHos API Docs.
This API SDK is intended to assist web applications of any kind to interact with the PayHos API server by utilizing its simple schematics. For a more modular usage, this library is designed such that bundlers with tree-shaking is enhanced.
Installation
Install @payhos/api via npm by running the following command:
npm install @payhos/api --save
Usage
Create an instance and call available methods from the instance created.
import { PayHos } from '@payhos/api';
// or
const { PayHos } = require('@payhos/api');
const payhos = new PayHos('<YOUR API TOKEN>');
// You can access each of PayHos' API features as follows:
const sms = payhos.sms;
const email = payhos.email;
SMS
Visit Send SMS with PayHos for more information on SMS dodumentations.
const sms = payhos.sms;
const data = {
message: 'Hello there, this is a test message from PayHos SDK',
recipients: ['+2348166666666', '+2348055555555'],
senderId: 'PayHos',
};
// to send SMS
sms.send(data).then(response => {
// message(s) sent successfully
console.log(response);
}).catch(err => {
console.log(err);
});
For detailed documentations on sending emails with PayHos API and other supported SDKs, visit Sending Emails with PayHos
const email = payhos.email;
const data = {
subject: 'Test Email',
content: `Hey <strong>Alice</strong>, this is a test email message from <a href="https://payhos.com">PayHos API Hub</a>`,
customData: {},
recipients: [
{email: '[email protected]'},
{ name: 'Alice', email: '[email protected]' }
],
from: {
name: 'PayHos',
email: '[email protected]'
}
};
// to send email
email.send(data).then(response => {
// message(s) sent successfully
console.log(response);
}).catch(err => {
console.log(err);
});