0.0.1 • Published 1 year ago

@abdouhugo/email-verifly-client v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Autoresponders

Install

create Autoresponder instance

// npm install --save https://github.com/hugo-abdou/autoresponder

// 1, create file called autoresponder.{js,ts} on your project
// 2, and initialize  the Autoresponder instance
// 3, pass the config
const autoresponder = require("@abdouhugo/autoresponders").default;
const autoresponder = new Autoresponder({
    aweber: {
        endpoint: "https://api.aweber.com/1.0",
        oauth_endpoint: "https://auth.aweber.com",
        scopes: "account.read list.read subscriber.write",
        client_id: "your_aweber_client_id",
        client_secret: "your_aweber_client_secret",
        redirect_uri: "your_project_url/aweber",
    },
    mailchimp: {
        endpoint: "https://<dc>.api.mailchimp.com/3.0",
    },
    getresponse: {
        endpoint: "https://api.getresponse.com/v3",
    },
    sendinblue: {
        endpoint: "https://api.sendinblue.com/v3",
    },
    // this two options is required if you are using pabbly or zapier even if empty
    pabbly: {},
    zapier: {},
});

// export the instance
exports.modules = autoresponder;

Available drivers

getresponse , sendinblue , mailchimp , aweber , zapier , pabbly

Check if Autoresponder need OAuth

// import the instance from the file you create befor ( autoresponder.{js,ts} )
const autoresponder = require("autoresponder.{js,ts}");
// no params needed if you whant to check withOAuth
const driver = autoresponder.create();

if (driver.withOAuth()) {
    // OAuth logic  login or get tocken ext...
} else {
    // normal code
}

// you can change the requests timeout by calling the setTimout function on the driver before you call the apis
driver.setTimeout(500);

Getresponse And Sendinblue

// import the instance from the file you create befor ( autoresponder.{js,ts} )
const autoresponder = require("autoresponder.{js,ts}");
const driver = autoresponder.create("getresponse or sendinblue", {
    apiKey: user_key,
});

// test the api
await driver.testApi();

// get the list of categories from autoresponder
await driver.getList();

//  add subscriber to list (category)
await driver.addSubscriber(
    "list_id",
    "exampl@email.com",
    "user_first_name",
    "user_last_name"
);

Mailchimp

const autoresponder = require("autoresponder.{js,ts}");
const driver = autoresponder.create("mailchimp", {
    apiKey: user_key,
    datacenter: api_datacenter,
});

// test the api
await driver.testApi();

// get the list of categories from autoresponder
await driver.getList();

//  add subscriber to list (category)
await driver.addSubscriber(
    "list_id",
    "exampl@email.com",
    "user_first_name",
    "user_last_name"
);

Aweber

const autoresponder = require("autoresponder.{js,ts}");
const driver = autoresponder.create("aweber", {
    access_token: user_token,
    refresh_token: user_refresh_token,
    expires_in: user_expires_in,
});

// return the login url of aweber you nead to redirect the user to this url
// and you nead a webhook to catch the code from aweber when user login successfuly
await driver.getAuthorizationUrl();

//return access token from aweber its need the code from aweber webhook
//you need to save the returned data on databas
await driver.getAccessToken(code);

//test the api
await driver.testApi();

// get the list of categories from autoresponder
await driver.getList();

// add subscriber to list (category)
await driver.addSubscriber(
    "list_id",
    "exampl@email.com",
    "user_first_name",
    "user_last_name"
);

Zapier Pabbly

const autoresponder = require("autoresponder.{js,ts}");
const driver = autoresponder.create("zapier or pabbly", {
    url: webhook_url,
});

// send your data  to autoresponder
await driver.post(
    email:string,
    firstName:string,
    lasName:string,
);