Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ndustrial/contxt-sdk

Package Overview
Dependencies
Maintainers
18
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndustrial/contxt-sdk - npm Package Compare versions

Comparing version 2.8.0 to 2.8.1

6

CHANGELOG.md

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

## [v2.8.1](http://github.com/ndustrialio/contxt-sdk-js/tree/v2.8.1) (2020-01-30)
**Added**
- Added an additional parameter, `subscribeOpts` to `Events#subscribeUser`.
## [v2.8.0](http://github.com/ndustrialio/contxt-sdk-js/tree/v2.8.0) (2020-01-29)

@@ -2,0 +8,0 @@

5

docs/Events.md

@@ -17,3 +17,3 @@ <a name="Events"></a>

* [.getUserInfo(userId)](#Events+getUserInfo) ⇒ <code>Promise</code>
* [.subscribeUser(userId, eventId)](#Events+subscribeUser) ⇒ <code>Promise</code>
* [.subscribeUser(userId, eventId, subscribeOpts)](#Events+subscribeUser) ⇒ <code>Promise</code>
* [.unsubscribeUser(userId, userEventSubscriptionId)](#Events+unsubscribeUser) ⇒ <code>Promise</code>

@@ -194,3 +194,3 @@ * [.update(eventId, update)](#Events+update) ⇒ <code>Promise</code>

### contxtSdk.events.subscribeUser(userId, eventId) ⇒ <code>Promise</code>
### contxtSdk.events.subscribeUser(userId, eventId, subscribeOpts) ⇒ <code>Promise</code>
Subscribes an user to an event

@@ -209,2 +209,3 @@

| eventId | <code>string</code> | The ID of the event |
| subscribeOpts | <code>Object</code> | Optional parameters to provide when subscribing the user |

@@ -211,0 +212,0 @@ **Example**

@@ -362,2 +362,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

* @param {string} eventId The ID of the event
* @param {Object} subscribeOpts Optional parameters to provide when subscribing the user
*

@@ -378,2 +379,4 @@ * @returns {Promise}

value: function subscribeUser(userId, eventId) {
var subscribeOpts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!userId) {

@@ -387,3 +390,3 @@ return Promise.reject(new Error('A user ID is required for subscribing a user to an event'));

return this._request.post(this._baseUrl + '/users/' + userId + '/events/' + eventId).then(function (response) {
return this._request.post(this._baseUrl + '/users/' + userId + '/events/' + eventId, toSnakeCase(subscribeOpts)).then(function (response) {
return toCamelCase(response);

@@ -390,0 +393,0 @@ });

@@ -377,2 +377,3 @@ 'use strict';

* @param {string} eventId The ID of the event
* @param {Object} subscribeOpts Optional parameters to provide when subscribing the user
*

@@ -393,2 +394,4 @@ * @returns {Promise}

value: function subscribeUser(userId, eventId) {
var subscribeOpts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (!userId) {

@@ -402,3 +405,3 @@ return Promise.reject(new Error('A user ID is required for subscribing a user to an event'));

return this._request.post(this._baseUrl + '/users/' + userId + '/events/' + eventId).then(function (response) {
return this._request.post(this._baseUrl + '/users/' + userId + '/events/' + eventId, (0, _objects.toSnakeCase)(subscribeOpts)).then(function (response) {
return (0, _objects.toCamelCase)(response);

@@ -405,0 +408,0 @@ });

2

package.json
{
"name": "@ndustrial/contxt-sdk",
"version": "2.8.0",
"version": "2.8.1",
"description": "",

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

@@ -346,2 +346,3 @@ import has from 'lodash.has';

* @param {string} eventId The ID of the event
* @param {Object} subscribeOpts Optional parameters to provide when subscribing the user
*

@@ -358,3 +359,3 @@ * @returns {Promise}

*/
subscribeUser(userId, eventId) {
subscribeUser(userId, eventId, subscribeOpts = {}) {
if (!userId) {

@@ -373,3 +374,6 @@ return Promise.reject(

return this._request
.post(`${this._baseUrl}/users/${userId}/events/${eventId}`)
.post(
`${this._baseUrl}/users/${userId}/events/${eventId}`,
toSnakeCase(subscribeOpts)
)
.then((response) => toCamelCase(response));

@@ -376,0 +380,0 @@ }

@@ -680,9 +680,9 @@ import omit from 'lodash.omit';

context('when all the required parameters are provided', function() {
let event;
let expectedSubscription;
let promise;
let request;
let event;
let user;
let subscriptionFromServer;
let toCamelCase;
let user;

@@ -706,2 +706,3 @@ beforeEach(function() {

};
toCamelCase = sinon

@@ -736,2 +737,66 @@ .stub(objectUtils, 'toCamelCase')

context('when the optional parameter is provided', function() {
let event;
let expectedOpts;
let expectedSubscription;
let promise;
let request;
let subscriptionFromServer;
let subscriptionOpts;
let toSnakeCase;
let user;
beforeEach(function() {
event = fixture.build('event');
user = fixture.build('contxtUser');
expectedSubscription = fixture.build('userEventSubscription');
subscriptionFromServer = fixture.build(
'userEventSubscription',
expectedSubscription,
{
fromServer: true
}
);
request = {
...baseRequest,
post: sinon.stub().resolves(subscriptionFromServer)
};
subscriptionOpts = {
mediumType: 'email'
};
expectedOpts = {
medium_type: 'email'
};
sinon.stub(objectUtils, 'toCamelCase').returns(expectedSubscription);
toSnakeCase = sinon
.stub(objectUtils, 'toSnakeCase')
.returns(expectedOpts);
const events = new Events(baseSdk, request);
events._baseUrl = expectedHost;
promise = events.subscribeUser(user.id, event.id, subscriptionOpts);
});
it('creates the user event subscription', function() {
return promise.then(() => {
expect(request.post).to.be.calledWith(
`${expectedHost}/users/${user.id}/events/${event.id}`,
expectedOpts
);
});
});
it('formats the opts to snake case', function() {
return promise.then(() => {
expect(toSnakeCase).to.be.calledWith(subscriptionOpts);
});
});
});
context('when the user ID is not provided', function() {

@@ -738,0 +803,0 @@ it('throws an error', function() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc