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

@ndustrial/contxt-sdk

Package Overview
Dependencies
Maintainers
6
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 0.0.6 to 0.0.7

4

CHANGELOG.md

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

## [v0.0.7](http://github.com/ndustrialio/contxt-sdk-js/tree/v0.0.7) (2018-03-29)
**Renamed**
- Facilities#updateInfo to Facilities#createOrUpdateInfo so that what the method does is more obvious
## [v0.0.6](http://github.com/ndustrialio/contxt-sdk-js/tree/v0.0.6) (2018-03-28)

@@ -2,0 +6,0 @@ **Added**

48

docs/Facilities.md

@@ -12,2 +12,3 @@ <a name="Facilities"></a>

* [.create(options)](#Facilities+create) ⇒ <code>Promise</code>
* [.createOrUpdateInfo(facilityId, update)](#Facilities+createOrUpdateInfo) ⇒ <code>Promise</code>
* [.delete(facilityId)](#Facilities+delete) ⇒ <code>Promise</code>

@@ -18,3 +19,2 @@ * [.get(facilityId)](#Facilities+get) ⇒ <code>Promise</code>

* [.update(facilityId, update)](#Facilities+update) ⇒ <code>Promise</code>
* [.updateInfo(facilityId, update)](#Facilities+updateInfo) ⇒ <code>Promise</code>

@@ -67,2 +67,25 @@ <a name="new_Facilities_new"></a>

```
<a name="Facilities+createOrUpdateInfo"></a>
### contxtSdk.facilities.createOrUpdateInfo(facilityId, update) ⇒ <code>Promise</code>
Creates or updates a facility's info (NOTE: This refers to the facility_info model)
API Endpoint: '/facilities/:facilityId/info?should_update=true'
Method: POST
**Kind**: instance method of [<code>Facilities</code>](#Facilities)
**Fulfill**: <code>undefined</code>
**Reject**: <code>Error</code>
| Param | Type | Description |
| --- | --- | --- |
| facilityId | <code>number</code> | The id of the facility to update |
| update | <code>Object</code> | An object containing the facility info for the facility |
**Example**
```js
contxtSdk.facilities.createOrUpdateInfo(25, {
square_feet: '10000'
});
```
<a name="Facilities+delete"></a>

@@ -185,24 +208,1 @@

```
<a name="Facilities+updateInfo"></a>
### contxtSdk.facilities.updateInfo(facilityId, update) ⇒ <code>Promise</code>
Updates a facility's info (NOTE: This refers to the facility_info model)
API Endpoint: '/facilities/:facilityId/info'
Method: POST
**Kind**: instance method of [<code>Facilities</code>](#Facilities)
**Fulfill**: <code>undefined</code>
**Reject**: <code>Error</code>
| Param | Type | Description |
| --- | --- | --- |
| facilityId | <code>number</code> | The id of the facility to update |
| update | <code>Object</code> | An object containing the updated facility info for the facility |
**Example**
```js
contxtSdk.facilities.updateInfo(25, {
square_feet: '10000'
});
```

@@ -330,2 +330,26 @@ import axios from 'axios';

}, {
key: 'createOrUpdateInfo',
value: function createOrUpdateInfo(facilityId, update) {
if (!facilityId) {
return Promise.reject(new Error("A facility id is required to update a facility's info."));
}
if (!update) {
return Promise.reject(new Error("An update is required to update a facility's info."));
}
if (!lodash_isplainobject(update)) {
return Promise.reject(new Error('The facility info update must be a well-formed object with the data you wish to update.'));
}
var options = {
params: {
should_update: true
}
};
return this._request.post(this._baseUrl + '/facilities/' + facilityId + '/info', update, options);
}
}, {
key: 'delete',

@@ -403,20 +427,2 @@ value: function _delete(facilityId) {

}, {
key: 'updateInfo',
value: function updateInfo(facilityId, update) {
if (!facilityId) {
return Promise.reject(new Error("A facility id is required to update a facility's info."));
}
if (!update) {
return Promise.reject(new Error("An update is required to update a facility's info."));
}
if (!lodash_isplainobject(update)) {
return Promise.reject(new Error('The facility info update must be a well-formed object with the data you wish to update.'));
}
return this._request.post(this._baseUrl + '/facilities/' + facilityId + '/info', update);
}
}, {
key: '_formatFacilityFromServer',

@@ -423,0 +429,0 @@ value: function _formatFacilityFromServer() {

@@ -334,2 +334,26 @@ 'use strict';

}, {
key: 'createOrUpdateInfo',
value: function createOrUpdateInfo(facilityId, update) {
if (!facilityId) {
return Promise.reject(new Error("A facility id is required to update a facility's info."));
}
if (!update) {
return Promise.reject(new Error("An update is required to update a facility's info."));
}
if (!lodash_isplainobject(update)) {
return Promise.reject(new Error('The facility info update must be a well-formed object with the data you wish to update.'));
}
var options = {
params: {
should_update: true
}
};
return this._request.post(this._baseUrl + '/facilities/' + facilityId + '/info', update, options);
}
}, {
key: 'delete',

@@ -407,20 +431,2 @@ value: function _delete(facilityId) {

}, {
key: 'updateInfo',
value: function updateInfo(facilityId, update) {
if (!facilityId) {
return Promise.reject(new Error("A facility id is required to update a facility's info."));
}
if (!update) {
return Promise.reject(new Error("An update is required to update a facility's info."));
}
if (!lodash_isplainobject(update)) {
return Promise.reject(new Error('The facility info update must be a well-formed object with the data you wish to update.'));
}
return this._request.post(this._baseUrl + '/facilities/' + facilityId + '/info', update);
}
}, {
key: '_formatFacilityFromServer',

@@ -427,0 +433,0 @@ value: function _formatFacilityFromServer() {

{
"name": "@ndustrial/contxt-sdk",
"version": "0.0.6",
"version": "0.0.7",
"description": "",

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

@@ -97,2 +97,44 @@ import isPlainObject from 'lodash.isplainobject';

/**
* Creates or updates a facility's info (NOTE: This refers to the facility_info model)
*
* API Endpoint: '/facilities/:facilityId/info?should_update=true'
* Method: POST
*
* @param {number} facilityId The id of the facility to update
* @param {Object} update An object containing the facility info for the facility
*
* @returns {Promise}
* @fulfill {undefined}
* @reject {Error}
*
* @example
* contxtSdk.facilities.createOrUpdateInfo(25, {
* square_feet: '10000'
* });
*/
createOrUpdateInfo(facilityId, update) {
if (!facilityId) {
return Promise.reject(new Error("A facility id is required to update a facility's info."));
}
if (!update) {
return Promise.reject(new Error("An update is required to update a facility's info."));
}
if (!isPlainObject(update)) {
return Promise.reject(
new Error('The facility info update must be a well-formed object with the data you wish to update.')
);
}
const options = {
params: {
should_update: true
}
};
return this._request.post(`${this._baseUrl}/facilities/${facilityId}/info`, update, options);
}
/**
* Deletes a facility

@@ -248,38 +290,2 @@ *

/**
* Updates a facility's info (NOTE: This refers to the facility_info model)
*
* API Endpoint: '/facilities/:facilityId/info'
* Method: POST
*
* @param {number} facilityId The id of the facility to update
* @param {Object} update An object containing the updated facility info for the facility
*
* @returns {Promise}
* @fulfill {undefined}
* @reject {Error}
*
* @example
* contxtSdk.facilities.updateInfo(25, {
* square_feet: '10000'
* });
*/
updateInfo(facilityId, update) {
if (!facilityId) {
return Promise.reject(new Error("A facility id is required to update a facility's info."));
}
if (!update) {
return Promise.reject(new Error("An update is required to update a facility's info."));
}
if (!isPlainObject(update)) {
return Promise.reject(
new Error('The facility info update must be a well-formed object with the data you wish to update.')
);
}
return this._request.post(`${this._baseUrl}/facilities/${facilityId}/info`, update);
}
/**
* Normalizes the facility object returned from the API server

@@ -286,0 +292,0 @@ *

@@ -122,2 +122,66 @@ import omit from 'lodash.omit';

describe('createOrUpdateInfo', function() {
context('when all required information is available', function() {
let expectedHost;
let facilityId;
let facilityInfoUpdate;
let promise;
beforeEach(function() {
expectedHost = faker.internet.url();
facilityId = fixture.build('facility').id;
facilityInfoUpdate = fixture.build('facilityInfo');
const facilities = new Facilities(baseSdk, baseRequest);
facilities._baseUrl = expectedHost;
promise = facilities.createOrUpdateInfo(facilityId, facilityInfoUpdate);
});
it('updates the facility', function() {
expect(baseRequest.post).to.be.calledWith(
`${expectedHost}/facilities/${facilityId}/info`,
facilityInfoUpdate,
{ params: { should_update: true } }
);
});
it('returns a fulfilled promise', function() {
return expect(promise).to.be.fulfilled;
});
});
context('when there is missing or malformed required information', function() {
let facilities;
beforeEach(function() {
facilities = new Facilities(baseSdk, baseRequest);
});
it('throws an error when there is no provided facility id', function() {
const facilityInfoUpdate = fixture.build('facilityInfo');
const promise = facilities.createOrUpdateInfo(null, facilityInfoUpdate);
return expect(promise).to.be
.rejectedWith("A facility id is required to update a facility's info.");
});
it('throws an error when there is no update provided', function() {
const facility = fixture.build('facility');
const promise = facilities.createOrUpdateInfo(facility.id);
return expect(promise).to.be.rejectedWith("An update is required to update a facility's info.");
});
it('throws an error when the update is not an object', function() {
const facility = fixture.build('facility');
const promise = facilities.createOrUpdateInfo(facility.id, [facility.info]);
return expect(promise).to.be.rejectedWith(
'The facility info update must be a well-formed object with the data you wish to update.'
);
});
});
});
describe('delete', function() {

@@ -404,65 +468,2 @@ context('the facility id is provided', function() {

describe('updateInfo', function() {
context('when all required information is available', function() {
let expectedHost;
let facilityId;
let facilityInfoUpdate;
let promise;
beforeEach(function() {
expectedHost = faker.internet.url();
facilityId = fixture.build('facility').id;
facilityInfoUpdate = fixture.build('facilityInfo');
const facilities = new Facilities(baseSdk, baseRequest);
facilities._baseUrl = expectedHost;
promise = facilities.updateInfo(facilityId, facilityInfoUpdate);
});
it('updates the facility', function() {
expect(baseRequest.post).to.be.calledWith(
`${expectedHost}/facilities/${facilityId}/info`,
facilityInfoUpdate
);
});
it('returns a fulfilled promise', function() {
return expect(promise).to.be.fulfilled;
});
});
context('when there is missing or malformed required information', function() {
let facilities;
beforeEach(function() {
facilities = new Facilities(baseSdk, baseRequest);
});
it('throws an error when there is no provided facility id', function() {
const facilityInfoUpdate = fixture.build('facilityInfo');
const promise = facilities.updateInfo(null, facilityInfoUpdate);
return expect(promise).to.be
.rejectedWith("A facility id is required to update a facility's info.");
});
it('throws an error when there is no update provided', function() {
const facility = fixture.build('facility');
const promise = facilities.updateInfo(facility.id);
return expect(promise).to.be.rejectedWith("An update is required to update a facility's info.");
});
it('throws an error when the update is not an object', function() {
const facility = fixture.build('facility');
const promise = facilities.updateInfo(facility.id, [facility.info]);
return expect(promise).to.be.rejectedWith(
'The facility info update must be a well-formed object with the data you wish to update.'
);
});
});
});
describe('_formatFacilityFromServer', function() {

@@ -469,0 +470,0 @@ let expectedFacility;

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