suite-js-sdk

21.1.9 • Public • Published

suite-js-sdk

Codeship Status for emartech/suite-js-sdk Dependency Status

Simple Javascript wrapper for the Emarsys API.

Important: This library does not support WSSE authentication. It is intended only to be used by Emarsys add-ons and internal services.

Installation

npm install --save suite-js-sdk

Testing

npm test

Release

Releases are automatized with semantic-release. Whether a release is triggered, and whether it is major, minor, or patch increase, is based the on commit message, follow the conventions.

Emarsys API Hint

This wrapper tries to implement all available methods of the Emarsys API in a node fashion, exposing a Promise-only interface.

However, the Emarsys API lacks a decent amount of methods that you expect an API to provide. Thus, if methods are missing or a certain implementation style was chosen it is most likely due to the inconsistency of the API itself. Feel free to get in touch or submit a pull request if you encounter any problems.

Configuration and Setup

Debug

If you want to debug. Set your environment variables

DEBUG=suite-sdk,suiterequest

Authentication middleware

Prerequisites

The koa bodyparser module should be installed and in use before the use of the koaMiddleware.

npm install koa-bodyparser -S

In application configuration:

var bodyParser = require('koa-bodyparser');

var app = koa();
app.use(bodyParser());

Configuration

Set your environment variables

SUITE_ESCHER_SECRET=yourEscherSecret
SUITE_ESCHER_CREDENTIAL_SCOPE=yourEscherCredentialScope

Usage

var middleware = require('suite-js-sdk').authentication.koaMiddleware.getMiddleware();

If the authentication fails it throws an error with 401 code. If the authentication success it decorates the request with a validatedData property. It contains the signed parameters.

Translation middleware

Configuration

var middleware = require('suite-js-sdk').translations.koaMiddleware.decorateRenderWithTranslations();

The middleware use 'validatedData' from the request. 'validatedData' must contain an 'environment' property. If you want to load an admins language then 'validatedData' must contain a 'customer_id' and an 'admin_id' properties. If you want to load a specific language then 'validatedData' must contain a 'language' property.

Usage

Middleware decorates the render method. It will add 'translations' object as render data. It also adds a '_' method as render data. So you can use it for translations.

translations = {
    dialogs: {
        invitation: {
            confirmation: {
                message: 'test string with %s and with %s'
            }
        }
    }
}

in your jade file

p.message= _('dialogs.invitation.confirmation.message', [ 'firstParameter', 'second parameter'])

Interacting with the API

Authentication

Authenticate with the api credentials provided by your Emarsys account manager.

Set your environment variables

SUITE_API_KEY=yourApiKey
SUITE_API_SECRET=yourSecretKey

After in your Codebase

var SuiteAPI = require('suite-js-sdk').api;
var suiteAPI = SuiteAPI.create(options);

Options

  • {String} customerId: the id of the customer
  • {String} apiKey: API key
  • {String} apiSecret: API secret
  • {String} environment: API environment

SDK methods

Each of the following methods take a last options parameter as a last argument. With this options set you can override the customerId, escherOptions, etc. that you had defined when created an instance from the API client, like:

var SuiteAPI = require('suite-js-sdk').api;
var suiteAPI = SuiteAPI.create({
   customerId: 1083232
});

suiteAPI.administrator.getAdministrators({}, {
    customerId: 20234245
});

In the example above, the API will be called with customerId = 20234245.

Administrators

suiteAPI.administrator.getAdministrators(payload, options);
Get By Name

Data of an admin can be queried by providing its name.

suiteAPI.administrator.getAdministratorByName(payload, options);
suiteAPI.administrator.patchAdministrator(payload, options);
suiteAPI.administrator.createAdministrator(payload, options);
suiteAPI.administrator.deleteAdministrator(payload, options);
Disable

Changes the status of the admin to disabled so logging in will not be possible.

suiteAPI.administrator.disableAdministrator(payload, options);
Enable

Changes the status of the disabled admin back to enabled so logging in becomes possible.

suiteAPI.administrator.enableAdministrator(payload, options);
suiteAPI.administrator.getInterfaceLanguages(payload, options);

Returns the start pages of an administrator.

suiteAPI.administrator.getStartPages(payload, options);
suiteAPI.administrator.getAccessLevels(payload, options);
Promote to Superadmin

Levels up an admin to a superadmin.

suiteAPI.administrator.promoteToSuperadmin(payload, options);
Create Superadmin

Creates a superadmin.

suiteAPI.administrator.createSuperadmin(payload, options);
Invite Existing Administrator

Sets the status of the admin to disabled and invites the admin again. The admin can log in only after completing the necessary data on the invitation form.

suiteAPI.administrator.inviteExistingAdministrator(payload, options);

AutomationCenter

suiteAPI.automationCenter.programResource(payload, options);
suiteAPI.automationCenter.programsEntrypoints(payload, options);

Campaign

create
suiteAPI.campaign.create(payload, options);
update
suiteAPI.campaign.update(payload, options);

Condition

List
suiteAPI.condition.list(payload, options);
List with contact fields
suiteAPI.condition.listWithContactFields(payload, options);

Contact

suiteAPI.contact.getData(payload, options);

To return the contacts with string field ids, specify { stringIds: true } in the options.

suiteAPI.contact.getData(payload, { stringIds: true });
suiteAPI.contact.create(payload, options);
Merge
suiteAPI.contact.merge(payload, options);
suiteAPI.contact.update(payload, options);
suiteAPI.contact.createOrUpdate(payload, options);
suiteAPI.contact.delete(payload, options);
suiteAPI.contact.checkIds(payload, options);
suiteAPI.contact.lastChange(payload, options);

Contact List

suiteAPI.contactList.create(payload, options);
suiteAPI.contactList.list(payload, options);
suiteAPI.contactList.fetch(payload, options);
suiteAPI.contactList.add(payload, options);
suiteAPI.contactList.listContactLists(payload, options);
suiteAPI.contactList.count(payload, options);
suiteAPI.contactList.getContactsData(payload, options);
suiteAPI.contactList.deleteList(payload, options);

ExternalEvent

suiteAPI.externalEvent.create(payload, options);
suiteAPI.externalEvent.list(payload, options);
suiteAPI.externalEvent.get(payload, options);
suiteAPI.externalEvent.update(payload, options);
suiteAPI.externalEvent.delete(payload, options);
suiteAPI.externalEvent.trigger(payload, options);

Language

Translate

Lists available languages for a customer in the customer's own language.

suiteAPI.language.translate(payload, options);

Settings

suiteAPI.settings.getSettings(payload, options);
Get Corporate Domains

Lists the permitted corporate domains of the customer. If corporate domains are set, registration is possible only with those email addresses which meet these requirements.

suiteAPI.settings.getCorporateDomains(payload, options);
Set Corporate Domains

Accepted corporate domains can be defined.

suiteAPI.settings.setCorporateDomains(payload, options);
Get IP Restrictions

Lists the permitted IP address rules (e.g. 192.168.* allows IP addresses which start with these two numbers and can end in any numbers).

suiteAPI.settings.getIpRestrictions(payload, options);
Set IP Restrictions

Possible IP address rules can be defined.

suiteAPI.settings.setIpRestrictions(payload, options);
Get available languages
suiteAPI.settings.getLanguages(payload, options);
Get security settings

Get security settings (IP whitelisting enabled option)

suiteAPI.settings.getSecuritySettings(payload, options);
Set security settings

Set security settings (IP whitelisting enabled option)

suiteAPI.settings.setSecuritySettings(payload, options);
Get sender domains
suiteAPI.settings.getDeliverabilitySenderDomains(payload, options);
Set sender domain
suiteAPI.settings.setDeliverabilitySenderDomain(payload, options);

Email

suiteAPI.email.create(payload, options);
suiteAPI.email.copy(payload, options);
suiteAPI.email.updateSource(payload, options);
suiteAPI.email.launch(payload, options);
suiteAPI.email.launchList(payload, options);
suiteAPI.email.list(payload, options);
suiteAPI.email.get(payload, options);
suiteAPI.email.patch(payload, options);
suiteAPI.email.sendTestMail(payload, options);

The payload must contain an email_id, which is the broadcast campaign id

suiteAPI.email.broadcast(payload, options);
suiteAPI.email.getDeliveryStatus(payload, options);
suiteAPI.email.responses(payload, options);

Returns the summary of the responses of a launched, paused, activated or deactivated email campaign.

suiteAPI.email.getResponseSummary(payload, options);
Querying Email Personalizations

Lists all possible alternate texts with their email campaigns. Alternate texts are defined for a specific field, and displayed in the email campaign if this field has no value.

suiteAPI.email.getPersonalizations(payload, options);
Updating Email Personalizations

Updates alternate texts.

suiteAPI.email.setPersonalizations(payload, options);
suiteAPI.email.createTrackedLink(payload, options);
suiteAPI.email.getTrackedLinks(payload, options);
suiteAPI.email.updateTrackedLink(payload, options);
suiteAPI.email.deleteTrackedLinks(payload, options);
suiteAPI.email.getContacts(payload, options);
suiteAPI.email.deleteTrackedLinksBySource(payload, options);
suiteAPI.email.listPrograms(payload, options);

Segment

suiteAPI.segment.listContacts(payload, options);
suiteAPI.segment.countContacts(payload, options);
suiteAPI.segment.listSegments(payload, options);
suiteAPI.segment.getSegment(payload, options);
suiteAPI.segment.create(payload, options);
suiteAPI.segment.getContactCriteria(payload, options);
suiteAPI.segment.updateContactCriteria(payload, options);
suiteAPI.segment.runForSingleContact(payload, options);
suiteAPI.segment.singleContactRunStatus(payload, options);
suiteAPI.segment.runForMultipleContacts(payload, options);
suiteAPI.segment.multipleContactsRunStatus(payload, options);

Combined Segment

suiteAPI.combinedSegment.list(payload, options);
suiteAPI.combinedSegment.create(payload, options);
suiteAPI.combinedSegment.get(payload, options);
suiteAPI.combinedSegment.update(payload, options);

Purchases

List

Lists the purchases of customer for a date range.

suiteAPI.purchase.list(payload, options);
Stats

Statistics about the purchases of customer.

suiteAPI.purchase.stats(payload, options);

Contact Fields

suiteAPI.field.create(payload, options);
suiteAPI.field.get(payload, options);
suiteAPI.field.getChoices(payload, options);
suiteAPI.field.getMultipleChoices(payload, options);
suiteAPI.field.delete(payload, options);

Export

suiteAPI.export.getData(payload, options);
suiteAPI.export.getChanges(payload, options);

Keyring

Manage customer PKI options

list
suiteAPI.keyring.list(payload, options);
get
suiteAPI.keyring.get(payload, options);
create
suiteAPI.keyring.create(payload, options);
delete
suiteAPI.keyring.delete(payload, options);

Contact Sources

suiteAPI.source.create(payload, options);

suiteAPI.source.listSources(payload, options);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.0.0-beta30beta
21.1.967latest

Version History

VersionDownloads (Last 7 Days)Published
21.1.967
21.1.7352
21.1.6107
21.1.50
21.1.41
21.1.312
21.1.20
21.1.10
21.1.00
21.0.00
20.0.60
20.0.50
20.0.423
20.0.39
20.0.20
20.0.00
19.3.00
19.2.00
19.1.10
19.1.00
19.0.10
19.0.00
18.0.60
18.0.50
18.0.40
18.0.30
18.0.20
18.0.10
18.0.00
17.2.00
17.1.00
17.0.00
16.4.00
16.3.11
16.3.00
16.2.00
16.1.20
16.1.10
16.1.00
16.0.00
15.1.00
15.0.11
15.0.00
14.4.01
14.3.00
14.2.20
14.2.10
14.2.00
14.1.00
14.0.00
13.0.10
13.0.00
12.16.00
12.15.00
12.14.00
12.13.00
12.12.02
12.11.01
12.10.00
12.9.00
12.8.00
12.7.10
12.7.00
12.6.00
12.5.10
12.5.00
12.4.00
12.3.01
12.2.00
12.1.10
12.1.00
12.0.00
11.3.00
11.2.00
11.1.00
11.0.10
11.0.00
10.11.00
10.10.00
10.9.01
10.8.00
10.7.10
10.7.01
10.6.00
10.5.10
10.5.00
10.4.00
10.3.00
10.2.00
10.1.01
10.0.00
9.3.00
9.2.00
9.1.00
9.0.00
8.1.01
8.0.01
7.2.01
7.1.01
7.0.00
6.6.00
6.5.00
6.4.01
6.3.00
6.2.20
6.2.11
6.2.00
6.1.00
6.0.30
6.0.20
6.0.10
6.0.00
5.4.00
5.3.30
5.3.20
5.3.10
5.3.00
5.2.00
5.1.00
5.0.00
4.1.90
4.1.70
4.1.60
4.1.50
4.1.40
4.1.30
4.1.20
4.1.10
4.1.00
4.0.00
3.11.00
3.10.00
3.9.00
3.8.00
3.7.00
3.6.00
3.5.00
3.4.10
3.4.00
3.3.00
3.2.00
3.1.00
3.0.00
3.0.0-beta30
3.0.0-beta10
2.8.10
2.8.00
2.7.00
2.6.00
2.5.00
2.4.00
2.3.00
2.2.00
2.1.00
2.0.00
1.6.20
1.6.11
1.6.00
1.5.00
1.3.00
1.2.00
1.1.00
0.3.10
1.0.00
0.3.01
0.2.21
0.2.11
0.2.01
0.1.02

Package Sidebar

Install

npm i suite-js-sdk

Weekly Downloads

594

Version

21.1.9

License

MIT

Unpacked Size

234 kB

Total Files

88

Last publish

Collaborators

  • blacksonic
  • gergelyke
  • sviktor
  • draven
  • adambrunner
  • joco
  • gszabo
  • emarsys-deployer