Skip to content

Latest commit

 

History

History
369 lines (282 loc) · 9.69 KB

example-endpoints.md

File metadata and controls

369 lines (282 loc) · 9.69 KB

Table of Content

fetch event logs

'use strict';

const moment = require('moment');
const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.EventsController;

configuration.apiKey = 'your api_key here';

let startdate = moment('2016-03-13', 'YYYY-MM-DD');
let events = lib.EventsEnum.BOUNCE;
let sort = lib.SortEnum.DESC;
let enddate = moment('2020-05-26', 'YYYY-MM-DD');
let subject = 'test';
let email = '[email protected]';

const promise = controller.getEventsGET(startdate, events, sort, enddate, null, null, subject, null, null, email);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

fetch summary stats

'use strict';

const moment = require('moment');
const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.StatsController;

configuration.apiKey = 'your api_key here';

let startdate = moment('2016-03-13', 'YYYY-MM-DD');
let enddate = moment('2020-05-26', 'YYYY-MM-DD');
let aggregatedBy = lib.AggregatedByEnum.MONTH;

const promise = controller.getStatsGET(startdate, enddate, aggregatedBy);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

Domain Add

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.DomainController;

configuration.apiKey = 'your api_key here';

let body = new lib.DomainStruct();

body.domain = 'example.com';
body.envelopeName = 'test';

const promise = controller.addDomain(body);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

Domain delete

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.DomainDeleteController;

configuration.apiKey = 'your api_key here';

let body = new lib.DeleteDomain();

body.domain = 'example.com';

const promise = controller.deleteDomain(body);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

Suppression add

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.SuppressionController;

configuration.apiKey = 'your api_key here';

let body = new lib.AddEmailOrDomainToSuppressionList();

body.domain = 'example.com';
body.email = '[email protected]';

const promise = controller.addDomainOrEmailToSuppressionList(body);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

Suppression delete

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.SuppressionController;

configuration.apiKey = 'your api_key here';

let body = new lib.RemoveEmailOrDomainToSuppressionList();

body.domain = 'example.com';
body.email = '[email protected]';

const promise = controller.removeDomainOrEmailToSuppressionList(body);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

create subaccount

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.SubaccountsCreateSubaccountController;

configuration.apiKey = 'your api_key here';

let body = new lib.CreateSubaccount();

body.username = 'name';
body.email = 'email1.gmail.com';
body.setpassword = 'setpassword8';
body.password = 'pwd';

const promise = controller.createSubaccountsCreateSubaccountPOST(body);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

update subaccount

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.SubaccountsUpdateSubaccountController;

configuration.apiKey = 'your api_key here';

let body = new lib.UpdateSubaccount();

body.username = 'username';
body.newEmail = '[email protected]';
body.newPassword = '[email protected]';
body.confirmPassword = 'pwd';

const promise = controller.createSubaccountsUpdateSubaccountPOST(body);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

enable/disable subaccount

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.SubaccountsController;

configuration.apiKey = 'your api_key here';

let body = new lib.EnableOrDisableSubacoount();

body.username = 'username';
body.disabled = true;

const promise = controller.updateSubaccountsPATCH(body);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

delete subaccount

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.SubaccountsDeleteController;

configuration.apiKey = 'your api_key here';

let body = new lib.DeleteSubacoount();

body.username = 'username';

const promise = controller.deleteSubaccountsDeleteDELETE(body);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

set recurring credit in subaccount

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.SetrecurringcreditddetailsController;

configuration.apiKey = 'your api_key here';

let body = new lib.UpdateRecurringCredisOfSubaccount();

body.username = 'username';
body.recurringCredit = 100;
body.timeperiod = lib.TimeperiodEnum.WEEKLY;

const promise = controller.createSetrecurringcreditddetailsPOST(body);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

add credit in subaccount

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.SubaccountsSetsubaccountcreditController;

configuration.apiKey = 'your api_key here';

let body = new lib.UpdateCredisOfSubaccount();

body.username = 'username';
body.action = lib.ActionEnum.INCREASE;
body.amount = 100;

const promise = controller.createSubaccountsSetsubaccountcreditPOST(body);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});

get credit details of subaccount

'use strict';

const lib = require('lib');
const configuration = lib.Configuration;
const controller = lib.SubaccountsGetSubAccountsController;

configuration.apiKey = 'your api_key here';

let limit = '100';
let offset = '1';

const promise = controller.getSubaccountsGetSubAccountsGET(limit, offset);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'object'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});