Skip to content

Development #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 68 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ Returns DeviceHive models
* [DeviceListQuery](#DeviceListQuery)
* [DeviceTypeCountQuery](#DeviceTypeCountQuery)
* [DeviceTypeListQuery](#DeviceTypeListQuery)
* [DeviceTypeDeleteQuery](#DeviceTypeDeleteQuery)
* [PluginUpdateQuery](#PluginUpdateQuery)
* [NetworkCountQuery](#NetworkCountQuery)
* [NetworkListQuery](#NetworkListQuery)
* [NetworkDeleteQuery](#NetworkDeleteQuery)
* [NotificationListQuery](#NotificationListQuery)
* [NotificationPollManyQuery](#NotificationPollManyQuery)
* [NotificationPollQuery](#NotificationPollQuery)
Expand Down Expand Up @@ -510,7 +512,7 @@ Returns information about the current deviceType
* [.count(deviceTypeCountQuery)](#DeviceTypeAPI+count) ⇒ <code>Promise</code>
* [.insert(deviceType)](#DeviceTypeAPI+insert) ⇒ <code>Promise</code>
* [.update(deviceType)](#DeviceTypeAPI+update) ⇒ <code>Promise</code>
* [.delete(deviceTypeId)](#DeviceTypeAPI+delete) ⇒ <code>Promise</code>
* [.delete(deviceTypeDeleteQuery)](#DeviceTypeAPI+delete) ⇒ <code>Promise</code>

<a name="DeviceTypeAPI+get"></a>

Expand Down Expand Up @@ -559,13 +561,13 @@ Updates a deviceType

<a name="DeviceTypeAPI+delete"></a>

### deviceTypeAPI.delete(deviceTypeId) ⇒ <code>Promise</code>
### deviceTypeAPI.delete(deviceTypeDeleteQuery) ⇒ <code>Promise</code>
Deletes an existing deviceType


| Param | Type |
| --- | --- |
| deviceTypeId | <code>number</code> |
| deviceTypeDeleteQuery | <code>deviceTypeDeleteQuery</code> |

<a name="NetworkAPI"></a>

Expand All @@ -579,7 +581,7 @@ Returns information about the current network
* [.count(networkCountQuery)](#NetworkAPI+count) ⇒ <code>Promise</code>
* [.insert(network)](#NetworkAPI+insert) ⇒ <code>Promise</code>
* [.update(networkId, network)](#NetworkAPI+update) ⇒ <code>Promise</code>
* [.delete(networkId)](#NetworkAPI+delete) ⇒ <code>Promise</code>
* [.delete(networkDeleteQuery)](#NetworkAPI+delete) ⇒ <code>Promise</code>

<a name="NetworkAPI+get"></a>

Expand Down Expand Up @@ -629,12 +631,12 @@ Updates a network

<a name="NetworkAPI+delete"></a>

### networkAPI.delete(networkId) ⇒ <code>Promise</code>
### networkAPI.delete(networkDeleteQuery) ⇒ <code>Promise</code>
Deletes an existing network

| Param | Type |
| --- | --- |
| networkId | <code>number</code> |
| networkDeleteQuery | <code>networkDeleteQuery</code> |

<a name="PluginAPI"></a>

Expand Down Expand Up @@ -1131,7 +1133,7 @@ Returns information about the current deviceType
* [.count(deviceTypeCountQuery)](#DeviceTypeAPI+count) ⇒ <code>Promise</code>
* [.insert(deviceType)](#DeviceTypeAPI+insert) ⇒ <code>Promise</code>
* [.update(deviceType)](#DeviceTypeAPI+update) ⇒ <code>Promise</code>
* [.delete(deviceTypeId)](#DeviceTypeAPI+delete) ⇒ <code>Promise</code>
* [.delete(deviceTypeDeleteQuery)](#DeviceTypeAPI+delete) ⇒ <code>Promise</code>

<a name="DeviceTypeAPI+get"></a>

Expand Down Expand Up @@ -1190,13 +1192,13 @@ Updates a deviceType

<a name="DeviceTypeAPI+delete"></a>

### deviceTypeAPI.delete(deviceTypeId) ⇒ <code>Promise</code>
### deviceTypeAPI.delete(deviceTypeDeleteQuery) ⇒ <code>Promise</code>
Deletes an existing deviceType


| Param | Type |
| --- | --- |
| deviceTypeId | <code>number</code> |
| deviceTypeDeleteQuery | <code>deviceTypeDeleteQuery</code> |

<a name="NetworkAPI"></a>

Expand All @@ -1210,7 +1212,7 @@ Returns information about the current network
* [.count(networkCountQuery)](#NetworkAPI+count) ⇒ <code>Promise</code>
* [.insert(network)](#NetworkAPI+insert) ⇒ <code>Promise</code>
* [.update(network)](#NetworkAPI+update) ⇒ <code>Promise</code>
* [.delete(networkId)](#NetworkAPI+delete) ⇒ <code>Promise</code>
* [.delete(networkDeleteQuery)](#NetworkAPI+delete) ⇒ <code>Promise</code>

<a name="NetworkAPI+get"></a>

Expand Down Expand Up @@ -1269,14 +1271,14 @@ Updates a network

<a name="NetworkAPI+delete"></a>

### networkAPI.delete(networkId) ⇒ <code>Promise</code>
### networkAPI.delete(networkDeleteQuery) ⇒ <code>Promise</code>
Deletes an existing network

**Returns**: <code>Promise</code> - Network

| Param | Type |
| --- | --- |
| networkId | <code>number</code> |
| networkDeleteQuery | <code>networkDeleteQuery</code> |

<a name="PluginAPI"></a>

Expand Down Expand Up @@ -2280,6 +2282,33 @@ Creates new DeviceTypeListQuery model
### deviceTypeListQuery.toObject() ⇒ <code>Object</code>
Returns instance as a plain JS object

<a name="DeviceTypeDeleteQuery"></a>

## DeviceTypeDeleteQuery
DeviceTypeDeleteQuery class


* [DeviceTypeDeleteQuery](#DeviceTypeDeleteQuery)
* [new DeviceTypeDeleteQuery(options)](#new_DeviceTypeDeleteQuery_new)
* [.toObject()](#DeviceTypeDeleteQuery+toObject) ⇒ <code>Object</code>

<a name="new_DeviceTypeDeleteQuery_new"></a>

### new DeviceTypeDeleteQuery(options)
Creates new DeviceTypeDeleteQuery model


| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> | model options object |
| options.deviceTypeId | <code>number</code> | Id of device type |
| options.force | <code>boolean</code> | Flag, if true then it will delete device type with existing devices |

<a name="DeviceTypeDeleteQuery+toObject"></a>

### deviceTypeDeleteQuery.toObject() ⇒ <code>Object</code>
Returns instance as a plain JS object

<a name="NetworkCountQuery"></a>

## NetworkCountQuery
Expand Down Expand Up @@ -2338,6 +2367,33 @@ Creates new NetworkListQuery model
### networkListQuery.toObject() ⇒ <code>Object</code>
Returns instance as a plain JS object

<a name="NetworkDeleteQuery"></a>

## NetworkDeleteQuery
NetworkDeleteQuery class


* [NetworkDeleteQuery](#NetworkDeleteQuery)
* [new NetworkDeleteQuery(options)](#new_NetworkDeleteQuery_new)
* [.toObject()](#NetworkDeleteQuery+toObject) ⇒ <code>Object</code>

<a name="new_NetworkDeleteQuery_new"></a>

### new NetworkDeleteQuery(options)
Creates new NetworkDeleteQuery model


| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> | model options object |
| options.networkId | <code>number</code> | Id of network |
| options.force | <code>boolean</code> | Flag, if true then it will delete network with existing devices |

<a name="NetworkDeleteQuery+toObject"></a>

### networkDeleteQuery.toObject() ⇒ <code>Object</code>
Returns instance as a plain JS object

<a name="NotificationListQuery"></a>

## NotificationListQuery
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devicehive",
"version": "2.0.2",
"version": "2.0.3",
"description": "DeviceHive JS Library",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/DeviceHive.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ const DeviceCountQuery = require(`./models/query/DeviceCountQuery`);
const DeviceListQuery = require(`./models/query/DeviceListQuery`);
const DeviceTypeCountQuery = require(`./models/query/DeviceTypeCountQuery`);
const DeviceTypeListQuery = require(`./models/query/DeviceTypeListQuery`);
const DeviceTypeDeleteQuery = require('./models/query/DeviceTypeDeleteQuery');
const PluginUpdateQuery = require(`./models/query/PluginUpdateQuery`);
const NetworkCountQuery = require(`./models/query/NetworkCountQuery`);
const NetworkListQuery = require(`./models/query/NetworkListQuery`);
const NetworkDeleteQuery = require('./models/query/NetworkDeleteQuery');
const NotificationListQuery = require(`./models/query/NotificationListQuery`);
const NotificationPollManyQuery = require(`./models/query/NotificationPollManyQuery`);
const NotificationPollQuery = require(`./models/query/NotificationPollQuery`);
Expand Down Expand Up @@ -73,9 +75,11 @@ class DeviceHive extends EventEmitter {
DeviceListQuery: DeviceListQuery,
DeviceTypeCountQuery: DeviceTypeCountQuery,
DeviceTypeListQuery: DeviceTypeListQuery,
DeviceTypeDeleteQuery: DeviceTypeDeleteQuery,
PluginUpdateQuery: PluginUpdateQuery,
NetworkCountQuery: NetworkCountQuery,
NetworkListQuery: NetworkListQuery,
NetworkDeleteQuery: NetworkDeleteQuery,
NotificationListQuery: NotificationListQuery,
NotificationPollManyQuery: NotificationPollManyQuery,
NotificationPollQuery: NotificationPollQuery,
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/DeviceTypeAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const API = require('./API');
const ApiMap = require(`./transportResolvers/ApiMap`);
const DeviceTypeListQuery = require('../models/query/DeviceTypeListQuery');
const DeviceTypeCountQuery = require('../models/query/DeviceTypeCountQuery');
const DeviceTypeDeleteQuery = require('../models/query/DeviceTypeDeleteQuery');


/**
Expand Down Expand Up @@ -59,8 +60,8 @@ class DeviceTypeAPI extends API {
* @param {number} deviceTypeId
* @returns {Promise}
*/
delete(deviceTypeId) {
return this.send(ApiMap.deleteDeviceType, { deviceTypeId: deviceTypeId });
delete(deviceTypeDeleteQuery = new DeviceTypeDeleteQuery()) {
return this.send(ApiMap.deleteDeviceType, deviceTypeDeleteQuery.toObject());
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/controllers/NetworkAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const API = require('./API');
const ApiMap = require(`./transportResolvers/ApiMap`);
const NetworkListQuery = require('../models/query/NetworkListQuery');
const NetworkCountQuery = require('../models/query/NetworkCountQuery');
const NetworkDeleteQuery = require('../models/query/NetworkDeleteQuery');


/**
Expand Down Expand Up @@ -59,8 +60,8 @@ class NetworkAPI extends API {
* @param {number} networkId
* @returns {Promise} Network
*/
delete(networkId) {
return this.send(ApiMap.deleteNetwork, { networkId: networkId });
delete(networkDeleteQuery = new NetworkDeleteQuery()) {
return this.send(ApiMap.deleteNetwork, networkDeleteQuery.toObject());
}
}

Expand Down
51 changes: 51 additions & 0 deletions src/models/query/DeviceTypeDeleteQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const BaseModel = require(`../BaseModel`);


/**
* DeviceTypeDeleteQuery class
*/
class DeviceTypeDeleteQuery extends BaseModel {

/**
* Creates new DeviceTypeDeleteQuery model
* @param {object} options - model options object
* @param {string} options.deviceTypeId - deviceType's id
* @param {boolean} options.force - flag for force delete
*/
constructor({ deviceTypeId, force } = {}) {
super();

this.deviceTypeId = deviceTypeId;
this.force = force;
}

get deviceTypeId() {
return this._deviceTypeId;
}

set deviceTypeId(value) {
this._deviceTypeId = value;
}

get force() {
return this._force;
}

set force(value) {
this._force = value;
}

/**
* Returns instance as a plain JS object
* @returns {Object}
*/
toObject() {
return {
deviceTypeId: this.deviceTypeId,
force: this.force
}
}
}


module.exports = DeviceTypeDeleteQuery;
51 changes: 51 additions & 0 deletions src/models/query/NetworkDeleteQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const BaseModel = require(`../BaseModel`);


/**
* NetworkDeleteQuery class
*/
class NetworkDeleteQuery extends BaseModel {

/**
* Creates new NetworkDeleteQuery model
* @param {object} options - model options object
* @param {string} options.networkId - network's id
* @param {boolean} options.force - flag for force delete
*/
constructor({ networkId, force } = {}) {
super();

this.networkId = networkId;
this.force = force;
}

get networkId() {
return this._networkId;
}

set networkId(value) {
this._networkId = value;
}

get force() {
return this._force;
}

set force(value) {
this._force = value;
}

/**
* Returns instance as a plain JS object
* @returns {Object}
*/
toObject() {
return {
networkId: this.networkId,
force: this.force
}
}
}


module.exports = NetworkDeleteQuery;
Loading