Socket
Socket
Sign inDemoInstall

dispatch-node-sdk

Package Overview
Dependencies
Maintainers
1
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dispatch-node-sdk - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

lib/entities/Collection.tests.js

31

dist/lib/dispatch.js

@@ -13,6 +13,2 @@ 'use strict';

var _model = require('./model');
var _model2 = _interopRequireDefault(_model);
var _endpoints = require('./endpoints');

@@ -40,4 +36,2 @@

var DEFAULT_PER_PAGE = 20;
var Dispatch = function () {

@@ -54,3 +48,5 @@ function Dispatch(clientID, clientSecret) {

job: (0, _job2.default)(this),
jobs: new _Collection2.default(this, endpoints.JOBS)
jobs: new _Collection2.default(this, endpoints.JOBS),
jobOffers: new _Collection2.default(this, endpoints.JOB_OFFERS),
hybridJobs: new _Collection2.default(this, endpoints.HYBRID_JOBS)
};

@@ -220,3 +216,3 @@ }

/**
* Retrieve a single entity by ID. Promise resolves with a Model
* Retrieve a single entity by ID. Promise resolves with the raw data
*

@@ -235,21 +231,2 @@ * @param {String} endpoint the endpoint

}
/**
* Add a note to an entity
* @param {String} text Note text
* @param {String} entityType Entity type (e.g. "Job")
* @param {Number} entityID Entity ID
* @return {Promise}
*/
}, {
key: 'addNote',
value: function addNote(text, entityType, entityID) {
var note = new _model2.default({
description: text,
entity_type: entityType,
entity_id: entityID
}, endpoints.ATTACHMENTS, this.getAuthClient());
return note.save();
}
}]);

@@ -256,0 +233,0 @@

@@ -16,3 +16,4 @@ 'use strict';

var JOBS = exports.JOBS = '/v1/jobs';
var ORGANIZATIONS = exports.ORGANIZATIONS = '/v1/organizations';
var SURVEY_RESPONSES = exports.SURVEY_RESPONSES = '/v1/survey_responses';
var USERS = exports.USERS = '/v1/users';

@@ -31,3 +31,3 @@ "use strict";

return this.client.get(this.endpoint, query);
return this.client.getCollection(this.endpoint, query);
}

@@ -39,2 +39,22 @@ }, {

}
}, {
key: "create",
value: function create(data) {
return this.client.getAuthClient().post(this.endpoint, data);
}
}, {
key: "getSingleEndpoint",
value: function getSingleEndpoint(id) {
return this.endpoint + "/" + id;
}
}, {
key: "update",
value: function update(id, data) {
return this.client.getAuthClient().patch(this.getSingleEndpoint(id), data);
}
}, {
key: "delete",
value: function _delete(id) {
return this.client.getAuthClient().delete(this.getSingleEndpoint(id));
}
}]);

@@ -41,0 +61,0 @@

@@ -10,19 +10,18 @@ 'use strict';

exports.stringify = stringify;
function flattenObject(ob) {
function flattenObject(obj) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if (_typeof(ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
toReturn[i + '[' + x + ']'] = flatObject[x];
}
Object.getOwnPropertyNames(obj).forEach(function (prop) {
if (_typeof(obj[prop]) === 'object') {
(function () {
var flatObject = flattenObject(obj[prop]);
Object.getOwnPropertyNames(flatObject).forEach(function (prop2) {
toReturn[prop + '[' + prop2 + ']'] = flatObject[prop2];
});
})();
} else {
toReturn[i] = ob[i];
toReturn[prop] = obj[prop];
}
}
});
return toReturn;

@@ -29,0 +28,0 @@ }

import RawClient, { AUTH_MODE_NONE, AUTH_MODE_BEARER } from './rawClient';
import Model from './model';
import * as endpoints from './endpoints';

@@ -8,3 +7,2 @@ import * as queryString from './queryString';

import Collection from './entities/Collection';
const DEFAULT_PER_PAGE = 20;
export default class Dispatch {

@@ -18,2 +16,4 @@ constructor(clientID, clientSecret, host = 'https://api.dispatch.me') {

jobs: new Collection(this, endpoints.JOBS),
jobOffers: new Collection(this, endpoints.JOB_OFFERS),
hybridJobs: new Collection(this, endpoints.HYBRID_JOBS),
};

@@ -145,3 +145,3 @@ }

/**
* Retrieve a single entity by ID. Promise resolves with a Model
* Retrieve a single entity by ID. Promise resolves with the raw data
*

@@ -155,18 +155,2 @@ * @param {String} endpoint the endpoint

}
/**
* Add a note to an entity
* @param {String} text Note text
* @param {String} entityType Entity type (e.g. "Job")
* @param {Number} entityID Entity ID
* @return {Promise}
*/
addNote(text, entityType, entityID) {
const note = new Model({
description: text,
entity_type: entityType,
entity_id: entityID,
}, endpoints.ATTACHMENTS, this.getAuthClient());
return note.save();
}
}
import nock from 'nock';
import Dispatch from './dispatch';
import expect from 'expect';
import Model from './model';
import * as endpoints from './endpoints';

@@ -114,4 +112,3 @@ const testClientID = '12345';

});
});
});

@@ -11,4 +11,5 @@ export const ACCOUNTS = '/v1/accounts';

export const JOBS = '/v1/jobs';
export const ORGANIZATIONS = '/v1/organizations';
export const SURVEY_RESPONSES = '/v1/survey_responses';
export const USERS = '/v1/users';

@@ -14,3 +14,3 @@ /**

get(query = {}) {
return this.client.get(this.endpoint, query);
return this.client.getCollection(this.endpoint, query);
}

@@ -21,2 +21,18 @@

}
create(data) {
return this.client.getAuthClient().post(this.endpoint, data);
}
getSingleEndpoint(id) {
return `${this.endpoint}/${id}`;
}
update(id, data) {
return this.client.getAuthClient().patch(this.getSingleEndpoint(id), data);
}
delete(id) {
return this.client.getAuthClient().delete(this.getSingleEndpoint(id));
}
}

@@ -22,3 +22,3 @@ import * as endpoints from '../endpoints';

entity_id: id,
}
},
};

@@ -33,3 +33,3 @@ return client.getCollection(endpoints.ATTACHMENTS, query);

job_id: id,
}
},
});

@@ -43,6 +43,6 @@ },

job_id: id,
}
},
});
},
}
};
};

@@ -49,0 +49,0 @@

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

import expect, { spyOn } from 'expect';
import expect from 'expect';
import Dispatch from '../dispatch';
import nock from 'nock';
import * as endpoints from '../endpoints'
import * as endpoints from '../endpoints';
const testClientID = '12345';

@@ -28,3 +28,3 @@ const testClientSecret = '54321';

.reply(200, {
attachments:[{
attachments: [{
id: 1,

@@ -38,2 +38,3 @@ file_token: null,

expect(notes.length).toEqual(1);
expect(scope.isDone()).toEqual(true);
done();

@@ -61,3 +62,3 @@ }).catch(done);

.reply(200, {
attachments:[{
attachments: [{
id: 1,

@@ -71,2 +72,3 @@ file_token: 'asdf-1234',

expect(notes.length).toEqual(1);
expect(scope.isDone()).toEqual(true);
done();

@@ -100,3 +102,2 @@ }).catch(done);

});
});

@@ -1,18 +0,15 @@

function flattenObject(ob) {
let toReturn = {};
function flattenObject(obj) {
const toReturn = {};
for (let i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
let flatObject = flattenObject(ob[i]);
for (let x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
toReturn[`${i}[${x}]`] = flatObject[x];
}
Object.getOwnPropertyNames(obj).forEach(prop => {
if ((typeof obj[prop]) === 'object') {
const flatObject = flattenObject(obj[prop]);
Object.getOwnPropertyNames(flatObject).forEach(prop2 => {
toReturn[`${prop}[${prop2}]`] = flatObject[prop2];
});
} else {
toReturn[i] = ob[i];
toReturn[prop] = obj[prop];
}
}
});
return toReturn;

@@ -19,0 +16,0 @@ }

@@ -107,3 +107,3 @@ import { ensure, oneOf } from 'simplecheck';

headers,
}
};

@@ -110,0 +110,0 @@ if (body) {

@@ -9,6 +9,7 @@ import expect from 'expect';

const client = new RawClient({
authMode: AUTH_MODE_NONE
authMode: AUTH_MODE_NONE,
});
client.doRequest('GET', '/').catch(done);
expect(scope.isDone()).toEqual(true);
});
});
{
"name": "dispatch-node-sdk",
"version": "0.0.6",
"version": "0.0.7",
"description": "High- and low-level libraries for interacting with the Dispatch API",

@@ -10,3 +10,3 @@ "main": "dist/lib/index.js",

"test:watch": "npm test -- --watch",
"build": "node_modules/.bin/babel lib --out-dir dist/lib --ignore 'lib/*.tests.js'",
"build": "rm -rf dist && node_modules/.bin/babel lib --out-dir dist/lib --ignore '*.tests.js'",
"lint": "node_modules/.bin/eslint .",

@@ -13,0 +13,0 @@ "jscs": "jscs .",

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