mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: Payment system with voucher cards.
feat: Design with inversion dependency injection architecture. feat: Prettier http middleware. feat: Re-write items categories with preferred accounts.
This commit is contained in:
27
server/src/services/SMSClient/EasySmsClient.ts
Normal file
27
server/src/services/SMSClient/EasySmsClient.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import axios from 'axios';
|
||||
import SMSClientInterface from '@/services/SMSClient/SMSClientInterfaces';
|
||||
import config from '@/../config/config';
|
||||
|
||||
export default class EasySMSClient implements SMSClientInterface {
|
||||
clientName: string = 'easysms';
|
||||
|
||||
/**
|
||||
* Send message to given phone number via easy SMS client.
|
||||
* @param {string} to
|
||||
* @param {string} message
|
||||
*/
|
||||
send(to: string, message: string) {
|
||||
console.log(config);
|
||||
const API_KEY = config.easySMSGateway.api_key;
|
||||
const params = `action=send-sms&api_key=${API_KEY}=&to=${to}&sms=${message}&unicode=1`;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(`https://easysms.devs.ly/sms/api?${params}`)
|
||||
.then((response) => {
|
||||
if (response.code === 'ok') { resolve(); }
|
||||
else { reject(); }
|
||||
})
|
||||
.catch((error) => { reject(error) });
|
||||
});
|
||||
}
|
||||
}
|
||||
13
server/src/services/SMSClient/SMSAPI.ts
Normal file
13
server/src/services/SMSClient/SMSAPI.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import SMSClientInterface from '@/services/SMSClient/SMSClientInterface';
|
||||
|
||||
export default class SMSAPI {
|
||||
smsClient: SMSClientInterface;
|
||||
|
||||
constructor(smsClient: SMSClientInterface){
|
||||
this.smsClient = smsClient;
|
||||
}
|
||||
|
||||
sendMessage(to: string, message: string, extraParams: [], extraHeaders: []) {
|
||||
return this.smsClient.send(to, message);
|
||||
}
|
||||
}
|
||||
5
server/src/services/SMSClient/SMSClientInterface.ts
Normal file
5
server/src/services/SMSClient/SMSClientInterface.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
export default interface SMSClientInterface {
|
||||
clientName: string;
|
||||
send(to: string, message: string): boolean;
|
||||
}
|
||||
3
server/src/services/SMSClient/index.ts
Normal file
3
server/src/services/SMSClient/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import SMSAPI from './SMSAPI';
|
||||
|
||||
export default SMSAPI;
|
||||
Reference in New Issue
Block a user