fix(core): update
This commit is contained in:
@ -1,9 +1,53 @@
|
||||
import * as plugins from './mailgun.plugins';
|
||||
|
||||
export class MailgunAccount {
|
||||
public baseUrl = 'https://api.mailgun.net/v3';
|
||||
public apiToken: string;
|
||||
|
||||
|
||||
constructor(apiToken: string) {
|
||||
|
||||
constructor(apiTokenArg: string) {
|
||||
this.apiToken = apiTokenArg;
|
||||
}
|
||||
}
|
||||
|
||||
public getRequest(routeArg: string) {
|
||||
const requestUrl = `${this.baseUrl}${routeArg}`; // TODO;
|
||||
const response = plugins.smartrequest.request(routeArg, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `Basic ${plugins.smartstring.base64.encode(
|
||||
`api:key-a049e048b7029b9621c41b5682fadee9`
|
||||
)}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async postFormData(routeArg: string, formFields: plugins.smartrequest.IFormField[]) {
|
||||
const requestUrl = `${this.baseUrl}${routeArg}`; // TODO;
|
||||
const response = await plugins.smartrequest.postFormData(
|
||||
routeArg,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Basic ${plugins.smartstring.base64.encode(
|
||||
`api:key-a049e048b7029b9621c41b5682fadee9`
|
||||
)}`
|
||||
}
|
||||
},
|
||||
formFields
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* sends a SmartMail
|
||||
*/
|
||||
public sendSmartMail(smartmailArg: plugins.smartmail.Smartmail) {
|
||||
const domain = smartmailArg.options.from.split('@')[1];
|
||||
this.postFormData(`/${domain}/messages`, [
|
||||
{
|
||||
name: 'from',
|
||||
type: 'string',
|
||||
payload: smartmailArg.options.from
|
||||
}
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
// @pushrocks scope
|
||||
import * as smartmail from '@pushrocks/smartmail';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
|
||||
export {
|
||||
smartrequest,
|
||||
smartstring
|
||||
};
|
||||
export { smartmail, smartrequest, smartstring };
|
||||
|
Reference in New Issue
Block a user