Socket
Socket
Sign inDemoInstall

drip-nodejs

Package Overview
Dependencies
52
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.3 to 3.0.0

lib/errors.js

4

lib/accounts.js

@@ -9,3 +9,3 @@ module.exports = {

listAccounts(callback) {
return this.get('accounts', {}, callback);
return this.get('v2/accounts', {}, callback);
},

@@ -20,4 +20,4 @@ /**

fetchAccount(accountId, callback) {
return this.get(`accounts/${accountId}`, {}, callback);
return this.get(`v2/accounts/${accountId}`, {}, callback);
}
};

@@ -11,3 +11,3 @@ module.exports = {

listBroadcasts(options = {}, callback) {
return this.get(`${this.accountId}/broadcasts/`, { qs: options }, callback);
return this.get(`v2/${this.accountId}/broadcasts/`, { qs: options }, callback);
},

@@ -22,4 +22,4 @@ /**

fetchBroadcast(broadcastId, callback) {
return this.get(`${this.accountId}/broadcasts/${broadcastId}`, {}, callback);
return this.get(`v2/${this.accountId}/broadcasts/${broadcastId}`, {}, callback);
}
};

@@ -11,3 +11,3 @@ module.exports = {

listCampaigns(options = {}, callback) {
return this.get(`${this.accountId}/campaigns/`, { qs: options }, callback);
return this.get(`v2/${this.accountId}/campaigns/`, { qs: options }, callback);
},

@@ -22,3 +22,3 @@ /**

fetchCampaign(campaignId, callback) {
return this.get(`${this.accountId}/campaigns/${campaignId}`, {}, callback);
return this.get(`v2/${this.accountId}/campaigns/${campaignId}`, {}, callback);
},

@@ -33,3 +33,3 @@ /**

activateCampaign(campaignId, callback) {
return this.post(`${this.accountId}/campaigns/${campaignId}/activate`, {}, callback);
return this.post(`v2/${this.accountId}/campaigns/${campaignId}/activate`, {}, callback);
},

@@ -44,3 +44,3 @@ /**

pauseCampaign(campaignId, callback) {
return this.post(`${this.accountId}/campaigns/${campaignId}/pause`, {}, callback);
return this.post(`v2/${this.accountId}/campaigns/${campaignId}/pause`, {}, callback);
},

@@ -55,3 +55,3 @@ /**

listAllSubscribesToCampaign(campaignId, callback) {
return this.get(`${this.accountId}/campaigns/${campaignId}/subscribers`, {}, callback);
return this.get(`v2/${this.accountId}/campaigns/${campaignId}/subscribers`, {}, callback);
},

@@ -67,4 +67,4 @@ /**

subscribeToCampaign(campaignId, payload, callback) {
return this.post(`${this.accountId}/campaigns/${campaignId}/subscribers`, { payload }, callback);
return this.post(`v2/${this.accountId}/campaigns/${campaignId}/subscribers`, this.generateResource('subscribers', payload), callback);
}
};

@@ -11,3 +11,3 @@ module.exports = {

listConversions(options = {}, callback) {
return this.get(`${this.accountId}/goals/`, { qs: options }, callback);
return this.get(`v2/${this.accountId}/goals/`, { qs: options }, callback);
},

@@ -22,4 +22,4 @@ /**

fetchConversion(conversionId, callback) {
return this.get(`${this.accountId}/goals/${conversionId}`, {}, callback);
return this.get(`v2/${this.accountId}/goals/${conversionId}`, {}, callback);
}
};

@@ -9,4 +9,4 @@ module.exports = {

listAllCustomFields(callback) {
return this.get(`${this.accountId}/custom_field_identifiers/`, {}, callback);
return this.get(`v2/${this.accountId}/custom_field_identifiers/`, {}, callback);
}
};

@@ -10,3 +10,3 @@ module.exports = {

recordEvent(payload, callback) {
return this.post(`${this.accountId}/events`, { payload }, callback);
return this.post(`v2/${this.accountId}/events`, this.generateResource('events', payload), callback);
},

@@ -16,3 +16,4 @@ /**

*
* @param {object} payload - An object with event name and subscriber emails
* @param {object} payload - An array of event objects with at least
* an action and subscriber emails
* @param {callback} callback - An optional callback

@@ -22,3 +23,3 @@ * @returns {promise}

recordBatchEvents(payload, callback) {
return this.post(`${this.accountId}/events/batches`, { payload }, callback);
return this.post(`v2/${this.accountId}/events/batches`, this.generateResource('batches', { events: payload }), callback);
},

@@ -33,4 +34,4 @@ /**

listEventActions(options = {}, callback) {
return this.get(`${this.accountId}/event_actions/`, { qs: options }, callback);
return this.get(`v2/${this.accountId}/event_actions/`, { qs: options }, callback);
}
};

@@ -9,3 +9,3 @@ module.exports = {

listForms(callback) {
return this.get(`${this.accountId}/forms`, {}, callback);
return this.get(`v2/${this.accountId}/forms`, {}, callback);
},

@@ -20,4 +20,4 @@ /**

fetchForm(formId, callback) {
return this.get(`${this.accountId}/forms/${formId}`, {}, callback);
return this.get(`v2/${this.accountId}/forms/${formId}`, {}, callback);
}
};

@@ -0,6 +1,19 @@

const MissingAttributeError = require('./errors');
module.exports = {
baseUrl: 'https://api.getdrip.com/v2/',
baseUrl: 'https://api.getdrip.com/',
escapeString(string) {
return encodeURIComponent(string);
},
checkRequiredFields(payload, requiredFields, personRequest = false) {
if (!requiredFields.every((prop) => prop in payload)) {
throw new MissingAttributeError(`Fields: ${requiredFields} should all be present`);
}
if (!Object.prototype.hasOwnProperty.call(payload, 'email')
&& !Object.prototype.hasOwnProperty.call(payload, 'person_id')
&& personRequest) {
throw new MissingAttributeError('An email or person_id field is required');
}
}
};

@@ -0,1 +1,4 @@

const requestPromise = require('request-promise');
// Resources
const Accounts = require('./accounts');

@@ -9,3 +12,3 @@ const Broadcasts = require('./broadcasts');

const Orders = require('./orders');
const Purchases = require('./purchases');
const ShopperActivity = require('./shopper_activity');
const Subscribers = require('./subscribers');

@@ -16,9 +19,7 @@ const Subscriptions = require('./subscriptions');

const Users = require('./users');
const Webhooks = require('./webhooks');
const Workflows = require('./workflows');
const Webhooks = require('./webhooks');
// Utilities
const helper = require('./helpers');
const requestPromise = require('request-promise');
const VERSION = require('./version');

@@ -39,9 +40,7 @@

requestHeaders() {
const headers = {
'Content-Type': 'application/vnd.api+json',
return {
'Content-Type': 'application/json',
authorization: `${this.tokenType} ${this.token}`,
'User-Agent': `Drip NodeJS Wrapper ${VERSION}`
};
return headers;
}

@@ -61,2 +60,6 @@

generateResource(key, ...args) {
return { [key]: args };
}
get(url, data, callback) {

@@ -67,3 +70,2 @@ return this.request({

uri: helper.baseUrl + url,
body: data.payload,
qs: data.qs,

@@ -80,3 +82,3 @@ json: true,

uri: helper.baseUrl + url,
body: data.payload,
body: data,
qs: data.qs,

@@ -103,3 +105,3 @@ json: true,

uri: helper.baseUrl + url,
body: data.payload,
body: data,
qs: data.qs,

@@ -147,5 +149,2 @@ json: true,

// Purchases methods
Client.prototype.createPurchase = Purchases.createPurchase;
// Order methods

@@ -156,2 +155,7 @@ Client.prototype.createUpdateOrder = Orders.createUpdateOrder;

// Shopper Activity
Client.prototype.createUpdateCartActivity = ShopperActivity.createUpdateCartActivity;
Client.prototype.createUpdateOrderActivity = ShopperActivity.createUpdateOrderActivity;
Client.prototype.createUpdateProductActivity = ShopperActivity.createUpdateProductActivity;
// Subscriber methods

@@ -200,4 +204,1 @@ Client.prototype.listSubscribers = Subscribers.listSubscribers;

module.exports = init;
// Todo: create error logging function
// Todo: Handle auth errors separately from server errors

@@ -11,3 +11,3 @@ module.exports = {

createUpdateOrder(payload, callback) {
return this.post(`${this.accountId}/orders`, { payload }, callback);
return this.post(`v2/${this.accountId}/orders`, this.generateResource('orders', payload), callback);
},

@@ -18,3 +18,3 @@ /**

*
* @param {object} payload - An object of an array of multiple orders
* @param {object} payload - An array of multiple order objects
* @param {callback} callback - An optional callback

@@ -24,3 +24,3 @@ * @returns {promise}

createUpdateBatchOrders(payload, callback) {
return this.post(`${this.accountId}/orders/batches`, { payload }, callback);
return this.post(`v2/${this.accountId}/orders/batches`, this.generateResource('batches', { orders: payload }), callback);
},

@@ -36,4 +36,4 @@ /**

createUpdateRefund(payload, callback) {
return this.post(`${this.accountId}/refunds`, { payload }, callback);
return this.post(`v2/${this.accountId}/refunds`, this.generateResource('refunds', payload), callback);
}
};

@@ -0,3 +1,3 @@

const request = require('request');
const helpers = require('./helpers');
const request = require('request');

@@ -13,3 +13,3 @@ module.exports = {

listSubscribers(options = {}, callback) {
return this.get(`${this.accountId}/subscribers/`, { qs: options }, callback);
return this.get(`v2/${this.accountId}/subscribers/`, { qs: options }, callback);
},

@@ -24,3 +24,3 @@ /**

createUpdateSubscriber(payload, callback) {
return this.post(`${this.accountId}/subscribers`, { payload }, callback);
return this.post(`v2/${this.accountId}/subscribers`, this.generateResource('subscribers', payload), callback);
},

@@ -36,3 +36,3 @@ /**

const encodedIdOrEmail = helpers.escapeString(idOrEmail);
return this.get(`${this.accountId}/subscribers/${encodedIdOrEmail}`, {}, callback);
return this.get(`v2/${this.accountId}/subscribers/${encodedIdOrEmail}`, {}, callback);
},

@@ -49,3 +49,3 @@ /**

const encodedIdOrEmail = helpers.escapeString(idOrEmail);
return this.post(`${this.accountId}/subscribers/${encodedIdOrEmail}/remove`, { qs: { campaign_id: campaignId } }, callback);
return this.post(`v2/${this.accountId}/subscribers/${encodedIdOrEmail}/remove`, { qs: { campaign_id: campaignId } }, callback);
},

@@ -60,3 +60,3 @@ /**

unsubscribeBatchSubscribers(payload, callback) {
return this.post(`${this.accountId}/unsubscribes/batches`, { payload }, callback);
return this.post(`v2/${this.accountId}/unsubscribes/batches`, this.generateResource('batches', { subscribers: payload }), callback);
},

@@ -72,3 +72,3 @@ /**

const encodedIdOrEmail = helpers.escapeString(idOrEmail);
return this.post(`${this.accountId}/subscribers/${encodedIdOrEmail}/unsubscribe_all`, {}, callback);
return this.post(`v2/${this.accountId}/subscribers/${encodedIdOrEmail}/unsubscribe_all`, {}, callback);
},

@@ -84,3 +84,3 @@ /**

const encodedIdOrEmail = helpers.escapeString(idOrEmail);
return this.del(`${this.accountId}/subscribers/${encodedIdOrEmail}`, {}, callback);
return this.del(`v2/${this.accountId}/subscribers/${encodedIdOrEmail}`, {}, callback);
},

@@ -114,3 +114,3 @@ /**

{
url: `${helpers.baseUrl}${this.accountId}/subscribers/batches`,
url: `${helpers.baseUrl}v2/${this.accountId}/subscribers/batches`,
headers,

@@ -117,0 +117,0 @@ json: true,

@@ -10,4 +10,4 @@ module.exports = {

subscriberCampaignSubscriptions(subscriberId, callback) {
return this.get(`${this.accountId}/subscribers/${subscriberId}/campaign_subscriptions`, {}, callback);
return this.get(`v2/${this.accountId}/subscribers/${subscriberId}/campaign_subscriptions`, {}, callback);
}
};

@@ -11,3 +11,3 @@ const helpers = require('./helpers');

listAllTags(callback) {
return this.get(`${this.accountId}/tags`, {}, callback);
return this.get(`v2/${this.accountId}/tags`, {}, callback);
},

@@ -22,3 +22,3 @@ /**

tagSubscriber(payload, callback) {
return this.post(`${this.accountId}/tags`, { payload }, callback);
return this.post(`v2/${this.accountId}/tags`, this.generateResource('tags', payload), callback);
},

@@ -36,4 +36,4 @@ /**

const encodedTag = helpers.escapeString(tag);
return this.del(`${this.accountId}/subscribers/${encodedEmail}/tags/${encodedTag}`, {}, callback);
return this.del(`v2/${this.accountId}/subscribers/${encodedEmail}/tags/${encodedTag}`, {}, callback);
}
};
module.exports = {
fetchUser(callback) {
return this.get('user', {}, callback);
return this.get('v2/user', {}, callback);
}
};

@@ -1,1 +0,1 @@

module.exports = '2.1.2';
module.exports = '3.0.0';

@@ -9,3 +9,3 @@ module.exports = {

listWebhooks(callback) {
return this.get(`${this.accountId}/webhooks`, {}, callback);
return this.get(`v2/${this.accountId}/webhooks`, {}, callback);
},

@@ -20,3 +20,3 @@ /**

fetchWebhook(webhookId, callback) {
return this.get(`${this.accountId}/webhooks/${webhookId}`, {}, callback);
return this.get(`v2/${this.accountId}/webhooks/${webhookId}`, {}, callback);
},

@@ -32,3 +32,3 @@ /**

createWebhook(payload, callback) {
return this.post(`${this.accountId}/webhooks`, { payload }, callback);
return this.post(`v2/${this.accountId}/webhooks`, this.generateResource('webhooks', payload), callback);
},

@@ -43,4 +43,4 @@ /**

destroyWebhook(webhookId, callback) {
return this.del(`${this.accountId}/webhooks/${webhookId}`, {}, callback);
return this.del(`v2/${this.accountId}/webhooks/${webhookId}`, {}, callback);
}
};

@@ -10,3 +10,3 @@ module.exports = {

listTriggers(workflowId, callback) {
return this.get(`${this.accountId}/workflows/${workflowId}/triggers`, {}, callback);
return this.get(`v2/${this.accountId}/workflows/${workflowId}/triggers`, {}, callback);
},

@@ -22,3 +22,3 @@ /**

createTrigger(workflowId, payload, callback) {
return this.post(`${this.accountId}/workflows/${workflowId}/triggers`, { payload }, callback);
return this.post(`v2/${this.accountId}/workflows/${workflowId}/triggers`, this.generateResource('triggers', payload), callback);
},

@@ -35,4 +35,4 @@ /**

updateTrigger(workflowId, workflowTriggerId, payload, callback) {
return this.put(`${this.accountId}/workflows/${workflowId}/triggers/${workflowTriggerId}`, { payload }, callback);
return this.put(`v2/${this.accountId}/workflows/${workflowId}/triggers/${workflowTriggerId}`, this.generateResource('triggers', payload), callback);
}
};

@@ -13,3 +13,3 @@ const helpers = require('./helpers');

listAllWorkflows(options = {}, callback) {
return this.get(`${this.accountId}/workflows/`, { qs: options }, callback);
return this.get(`v2/${this.accountId}/workflows/`, { qs: options }, callback);
},

@@ -24,3 +24,3 @@ /**

fetchWorkflow(workflowId, callback) {
return this.get(`${this.accountId}/workflows/${workflowId}`, {}, callback);
return this.get(`v2/${this.accountId}/workflows/${workflowId}`, {}, callback);
},

@@ -35,3 +35,3 @@ /**

activateWorkflow(workflowId, callback) {
return this.post(`${this.accountId}/workflows/${workflowId}/activate`, {}, callback);
return this.post(`v2/${this.accountId}/workflows/${workflowId}/activate`, {}, callback);
},

@@ -46,3 +46,3 @@ /**

pauseWorkflow(workflowId, callback) {
return this.post(`${this.accountId}/workflows/${workflowId}/pause`, {}, callback);
return this.post(`v2/${this.accountId}/workflows/${workflowId}/pause`, {}, callback);
},

@@ -58,3 +58,3 @@ /**

startOnWorkflow(workflowId, payload, callback) {
return this.post(`${this.accountId}/workflows/${workflowId}/subscribers`, { payload }, callback);
return this.post(`v2/${this.accountId}/workflows/${workflowId}/subscribers`, this.generateResource('subscribers', payload), callback);
},

@@ -71,4 +71,4 @@ /**

const encodedIdOrEmail = helpers.escapeString(idOrEmail);
return this.del(`${this.accountId}/workflows/${workflowId}/subscribers/${encodedIdOrEmail}`, {}, callback);
return this.del(`v2/${this.accountId}/workflows/${workflowId}/subscribers/${encodedIdOrEmail}`, {}, callback);
}
};
{
"name": "drip-nodejs",
"version": "2.1.3",
"version": "3.0.0",
"description": "A complete NodeJS wrapper for connecting to the Drip v2 REST API",

@@ -8,8 +8,8 @@ "main": "./lib/index.js",

"request": "^2.88.0",
"request-promise": "^4.2.2"
"request-promise": "^4.2.5"
},
"devDependencies": {
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-jasmine": "^2.10.1",

@@ -21,3 +21,3 @@ "jasmine": "^2.99.0",

"test": "./node_modules/.bin/jasmine",
"lint": "./node_modules/.bin/eslint **/*.js"
"lint": "./node_modules/.bin/eslint ."
},

@@ -24,0 +24,0 @@ "repository": {

@@ -11,2 +11,44 @@ [![Build Status](https://travis-ci.org/samudary/drip-nodejs.svg?branch=master)](https://travis-ci.org/samudary/drip-nodejs)

## NOTE: Potential Breaking Changes for Version 3.0.0
Drip's documentation doesn't explicitly describe the required schema for each endpoint. In versions prior to 3 you would need to explicitly pass payloads with the required schema, which aren't obvious. In version 3 and later, I've attempted to make this a bit simpler. For example, batch endpoints will now only need you to pass an array of objects as:
```js
payload = [
{
email: 'user@example.com',
action: 'Purchased'
},
{
email: 'user@example.com',
action: 'Purchased'
}
]
// client.recordBatchEvents(payload, ...)
```
Prior to v3 changes you would need to do something like the following where the entire payload structure is defined:
```js
payload = {
batches: [
{
events: [
{
email: 'user@example.com',
action: 'Purchased'
},
{
email: 'user@example.com',
action: 'Purchased'
}
]
}
]
}
// client.recordBatchEvents(payload, ...)
```
This should help to get up and running simpler without much knowledge of the required schema. **However, existing users will need to take special note of these changes**.
## Authentication

@@ -36,3 +78,3 @@

### Broadcats
### Broadcasts
| Action | Method |

@@ -91,2 +133,9 @@ |--------------------------------------|------------------------------------------------------------------------------|

### Shopper Activity
| Action | Method |
|--------------------------------------|------------------------------------------------------------------------------|
| Create or update a cart for a customer | `client.createUpdateCartActivity(payload, callback)` |
| Create or update an order for a customer | `client.createUpdateOrderActivity(payload, callback)` |
| Create or update a product | `client.createUpdateProductActivity(payload, callback)` |
### Subscribers

@@ -93,0 +142,0 @@ | Action | Method |

@@ -67,3 +67,3 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('accounts', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/accounts', {}, undefined);
});

@@ -82,4 +82,4 @@

expect(client.get).toHaveBeenCalledWith('accounts/9999999', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/accounts/9999999', {}, undefined);
});
});

@@ -69,3 +69,3 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('9999999/broadcasts/', { qs: {} }, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/broadcasts/', { qs: {} }, undefined);
});

@@ -84,4 +84,4 @@

expect(client.get).toHaveBeenCalledWith('9999999/broadcasts/8888888', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/broadcasts/8888888', {}, undefined);
});
});

@@ -110,3 +110,3 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('9999999/campaigns/', { qs: {} }, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/campaigns/', { qs: {} }, undefined);
});

@@ -125,3 +125,3 @@

expect(client.get).toHaveBeenCalledWith('9999999/campaigns/4444444', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/campaigns/4444444', {}, undefined);
});

@@ -140,3 +140,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/campaigns/4444444/activate', {}, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/campaigns/4444444/activate', {}, undefined);
});

@@ -155,3 +155,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/campaigns/4444444/pause', {}, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/campaigns/4444444/pause', {}, undefined);
});

@@ -170,3 +170,3 @@

expect(client.get).toHaveBeenCalledWith('9999999/campaigns/4444444/subscribers', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/campaigns/4444444/subscribers', {}, undefined);
});

@@ -185,4 +185,4 @@

expect(client.post).toHaveBeenCalledWith('9999999/campaigns/4444444/subscribers', { payload: {} }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/campaigns/4444444/subscribers', { subscribers: [{}] }, undefined);
});
});

@@ -15,3 +15,3 @@ const client = require('../../lib/index')({ token: 'abc123', accountId: 9999999 });

it('should add content-type header', () => {
expect(headers['Content-Type']).toEqual('application/vnd.api+json');
expect(headers['Content-Type']).toEqual('application/json');
});

@@ -18,0 +18,0 @@

@@ -69,3 +69,3 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('9999999/goals/', { qs: {} }, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/goals/', { qs: {} }, undefined);
});

@@ -84,4 +84,4 @@

expect(client.get).toHaveBeenCalledWith('9999999/goals/999888', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/goals/999888', {}, undefined);
});
});

@@ -57,4 +57,4 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('9999999/custom_field_identifiers/', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/custom_field_identifiers/', {}, undefined);
});
});

@@ -78,3 +78,3 @@ const sinon = require('sinon');

expect(client.post).toHaveBeenCalledWith('9999999/events', { payload: { email: 'test@example.com', action: 'Purchased' } }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/events', { events: [{ email: 'test@example.com', action: 'Purchased' }] }, undefined);
});

@@ -85,3 +85,3 @@

client.recordBatchEvents({ email: 'test@example.com', action: 'Purchased' })
client.recordBatchEvents([{ email: 'test@example.com', action: 'Purchased' }])
.then((response) => {

@@ -94,3 +94,3 @@ expect(response.statusCode).toBe(200);

expect(client.post).toHaveBeenCalledWith('9999999/events/batches', { payload: { email: 'test@example.com', action: 'Purchased' } }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/events/batches', { batches: [{ events: [{ email: 'test@example.com', action: 'Purchased' }] }] }, undefined);
});

@@ -109,4 +109,4 @@

expect(client.get).toHaveBeenCalledWith('9999999/event_actions/', { qs: {} }, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/event_actions/', { qs: {} }, undefined);
});
});

@@ -69,3 +69,3 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('9999999/forms', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/forms', {}, undefined);
});

@@ -84,4 +84,4 @@

expect(client.get).toHaveBeenCalledWith('9999999/forms/5555555', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/forms/5555555', {}, undefined);
});
});

@@ -5,66 +5,64 @@ const sinon = require('sinon');

const order = {
orders: [{
email: 'ordertest@gmail.com',
provider: 'shopify',
upstream_id: 'abcdef',
identifier: 'Order_123456',
email: 'ordertest@gmail.com',
provider: 'shopify',
upstream_id: 'abcdef',
identifier: 'Order_123456',
amount: 4900,
tax: 100,
fees: 0,
discount: 0,
permalink: 'http://myorders.com/orders/123456',
currency_code: 'USD',
properties: {
size: 'medium',
color: 'red'
},
financial_state: 'paid',
fulfillment_state: 'fulfilled',
billing_address: {
name: 'Bill Billington',
first_name: 'Bill',
last_name: 'Billington',
company: 'Bills R US',
address_1: '123 Bill St.',
address_2: 'Apt. B',
city: 'Billtown',
state: 'CA',
zip: '01234',
country: 'United States',
phone: '555-555-5555',
email: 'bill@bills.com'
},
shipping_address: {
name: 'Ship Shippington',
first_name: 'Ship',
last_name: 'Shipington',
company: 'Shipping 4 Less',
address_1: '123 Ship St.',
address_2: 'null',
city: 'Shipville',
state: 'CA',
zip: '01234',
country: 'United States',
phone: '555-555-5555',
email: 'ship@shipping.com'
},
items: [{
id: '8888888',
product_id: '765432',
sku: '4444',
amount: 4900,
name: 'Canoe',
quantity: 1,
upstream_id: 'hijkl',
upstream_product_id: 'opqrs',
upstream_product_variant_id: 'zyxwv',
price: 4900,
tax: 100,
fees: 0,
discount: 0,
permalink: 'http://myorders.com/orders/123456',
currency_code: 'USD',
discount: 100,
taxable: true,
properties: {
size: 'medium',
color: 'red'
},
financial_state: 'paid',
fulfillment_state: 'fulfilled',
billing_address: {
name: 'Bill Billington',
first_name: 'Bill',
last_name: 'Billington',
company: 'Bills R US',
address_1: '123 Bill St.',
address_2: 'Apt. B',
city: 'Billtown',
state: 'CA',
zip: '01234',
country: 'United States',
phone: '555-555-5555',
email: 'bill@bills.com'
},
shipping_address: {
name: 'Ship Shippington',
first_name: 'Ship',
last_name: 'Shipington',
company: 'Shipping 4 Less',
address_1: '123 Ship St.',
address_2: 'null',
city: 'Shipville',
state: 'CA',
zip: '01234',
country: 'United States',
phone: '555-555-5555',
email: 'ship@shipping.com'
},
items: [{
id: '8888888',
product_id: '765432',
sku: '4444',
amount: 4900,
name: 'Canoe',
quantity: 1,
upstream_id: 'hijkl',
upstream_product_id: 'opqrs',
upstream_product_variant_id: 'zyxwv',
price: 4900,
tax: 100,
fees: 0,
discount: 100,
taxable: true,
properties: {
color: 'black'
}
}]
color: 'black'
}
}]

@@ -217,9 +215,7 @@ };

const refund = {
refunds: [{
upstream_id: 'tuvwx',
provider: 'my_store',
order_upstream_id: 'a1234567',
amount: 2000,
note: 'Incorrect size'
}]
upstream_id: 'tuvwx',
provider: 'my_store',
order_upstream_id: 'a1234567',
amount: 2000,
note: 'Incorrect size'
};

@@ -287,3 +283,3 @@

it('should create an order and call request with post', (done) => {
it('should create an order and call request with POST', (done) => {
expect(typeof client.createUpdateOrder).toEqual('function');

@@ -299,9 +295,9 @@

expect(client.post).toHaveBeenCalledWith('9999999/orders', { payload: order }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/orders', { orders: [order] }, undefined);
});
it('should post a batch of orders and call request with post', (done) => {
it('should post a batch of orders and call request with POST', (done) => {
expect(typeof client.createUpdateBatchOrders).toEqual('function');
client.createUpdateBatchOrders(batch)
client.createUpdateBatchOrders(batch.batches[0].orders)
.then((response) => {

@@ -314,6 +310,6 @@ expect(response.statusCode).toBe(202);

expect(client.post).toHaveBeenCalledWith('9999999/orders/batches', { payload: batch }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/orders/batches', batch, undefined);
});
it('should create a refund and call request with post', (done) => {
it('should create a refund and call request with POST', (done) => {
expect(typeof client.createUpdateRefund).toEqual('function');

@@ -329,4 +325,4 @@

expect(client.post).toHaveBeenCalledWith('9999999/refunds', { payload: refund }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/refunds', { refunds: [refund] }, undefined);
});
});

@@ -0,8 +1,8 @@

const request = require('request');
const sinon = require('sinon');
const client = require('../../lib/index')({ token: 'abc123', accountId: 9999999 });
const request = require('request');
const email = 'someone@example.com';
const campaignId = 456789;
const batchPayload = { batches: [{ subscribers: [{ email: 'someone@example.com' }] }] };
const batchPayload = [{ email: 'someone@example.com' }];

@@ -195,3 +195,3 @@ describe('Subscribers with callback', () => {

expect(client.get).toHaveBeenCalledWith('9999999/subscribers/', { qs: {} }, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/subscribers/', { qs: {} }, undefined);
});

@@ -210,3 +210,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/subscribers', { payload: { test_field: 'value' } }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/subscribers', { subscribers: [{ test_field: 'value' }] }, undefined);
});

@@ -225,3 +225,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/unsubscribes/batches', { payload: { batches: [{ subscribers: [{ email: 'someone@example.com' }] }] } }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/unsubscribes/batches', { batches: [{ subscribers: [{ email: 'someone@example.com' }] }] }, undefined);
});

@@ -240,3 +240,3 @@

expect(client.get).toHaveBeenCalledWith('9999999/subscribers/someone%40example.com', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/subscribers/someone%40example.com', {}, undefined);
});

@@ -255,3 +255,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/subscribers/someone%40example.com/remove', { qs: { campaign_id: campaignId } }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/subscribers/someone%40example.com/remove', { qs: { campaign_id: campaignId } }, undefined);
});

@@ -270,3 +270,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/subscribers/someone%40example.com/unsubscribe_all', {}, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/subscribers/someone%40example.com/unsubscribe_all', {}, undefined);
});

@@ -285,3 +285,3 @@

expect(client.del).toHaveBeenCalledWith('9999999/subscribers/someone%40example.com', {}, undefined);
expect(client.del).toHaveBeenCalledWith('v2/9999999/subscribers/someone%40example.com', {}, undefined);
});

@@ -288,0 +288,0 @@

@@ -59,4 +59,4 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('9999999/subscribers/abc123/campaign_subscriptions', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/subscribers/abc123/campaign_subscriptions', {}, undefined);
});
});

@@ -81,3 +81,3 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('9999999/tags', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/tags', {}, undefined);
});

@@ -96,3 +96,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/tags', { payload: { email, tag: 'Customer' } }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/tags', { tags: [{ email, tag: 'Customer' }] }, undefined);
});

@@ -111,4 +111,4 @@

expect(client.del).toHaveBeenCalledWith('9999999/subscribers/someone%40example.com/tags/Customer', {}, undefined);
expect(client.del).toHaveBeenCalledWith('v2/9999999/subscribers/someone%40example.com/tags/Customer', {}, undefined);
});
});

@@ -57,4 +57,4 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('user', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/user', {}, undefined);
});
});

@@ -91,3 +91,3 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('9999999/webhooks', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/webhooks', {}, undefined);
});

@@ -106,3 +106,3 @@

expect(client.get).toHaveBeenCalledWith('9999999/webhooks/456789', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/webhooks/456789', {}, undefined);
});

@@ -121,3 +121,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/webhooks', { payload: { hook_details: 'hook value' } }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/webhooks', { webhooks: [{ hook_details: 'hook value' }] }, undefined);
});

@@ -136,4 +136,4 @@

expect(client.del).toHaveBeenCalledWith('9999999/webhooks/456789', {}, undefined);
expect(client.del).toHaveBeenCalledWith('v2/9999999/webhooks/456789', {}, undefined);
});
});

@@ -82,3 +82,3 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('9999999/workflows/444555/triggers', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/workflows/444555/triggers', {}, undefined);
});

@@ -97,3 +97,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/workflows/444555/triggers', { payload: { provider: 'some_app' } }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/workflows/444555/triggers', { triggers: [{ provider: 'some_app' }] }, undefined);
});

@@ -112,4 +112,4 @@

expect(client.put).toHaveBeenCalledWith('9999999/workflows/444555/triggers/df1234', { payload: { provider: 'some_app' } }, undefined);
expect(client.put).toHaveBeenCalledWith('v2/9999999/workflows/444555/triggers/df1234', { triggers: [{ provider: 'some_app' }] }, undefined);
});
});

@@ -112,3 +112,3 @@ const sinon = require('sinon');

expect(client.get).toHaveBeenCalledWith('9999999/workflows/', { qs: {} }, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/workflows/', { qs: {} }, undefined);
});

@@ -127,3 +127,3 @@

expect(client.get).toHaveBeenCalledWith('9999999/workflows/444555', {}, undefined);
expect(client.get).toHaveBeenCalledWith('v2/9999999/workflows/444555', {}, undefined);
});

@@ -142,3 +142,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/workflows/444555/activate', {}, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/workflows/444555/activate', {}, undefined);
});

@@ -157,3 +157,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/workflows/444555/pause', {}, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/workflows/444555/pause', {}, undefined);
});

@@ -172,3 +172,3 @@

expect(client.post).toHaveBeenCalledWith('9999999/workflows/444555/subscribers', { payload: { email: 'test@example.com' } }, undefined);
expect(client.post).toHaveBeenCalledWith('v2/9999999/workflows/444555/subscribers', { subscribers: [{ email: 'test@example.com' }] }, undefined);
});

@@ -187,4 +187,4 @@

expect(client.del).toHaveBeenCalledWith('9999999/workflows/444555/subscribers/test%40example.com', {}, undefined);
expect(client.del).toHaveBeenCalledWith('v2/9999999/workflows/444555/subscribers/test%40example.com', {}, undefined);
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc