Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Park committed Dec 19, 2016
2 parents 0e25536 + c3e3e97 commit 98c2be3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 52 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ api.rosette(endpoint, function(err, res){
| targetScheme | name translation | No |
| options | relationships | No |
| accuracyMode | relationships | Yes |
| linked (deprecated) | entities | No |
| linkEntities | entities | No |
| explain | sentiment | No |
| morphology | morphology | Yes |
Expand Down
28 changes: 0 additions & 28 deletions examples/entities_linked.js

This file was deleted.

16 changes: 1 addition & 15 deletions lib/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,7 @@ function entities() {
entities.prototype.getResults = function(parameters, userKey, protocol, serviceURL, callback) {

if (parameters.documentFile != null) {
if (parameters.loadParams().linked == true) {
console.warn("entities/linked endpoint has been combined with /entities. Do not specify the linked parameter.");
parameters.loadFile(parameters.loadParams().documentFile, parameters, userKey, protocol, serviceURL, "entities/linked", callback);
} else {
parameters.loadFile(parameters.loadParams().documentFile, parameters, userKey, protocol, serviceURL, "entities", callback);
}



} else {

// validate parameters
Expand All @@ -57,13 +49,7 @@ entities.prototype.getResults = function(parameters, userKey, protocol, serviceU
return callback(new RosetteException("badArgument", "Cannot supply both Content and ContentUri", "bad arguments"));
} else {
// configure URL
if (parameters.loadParams().linked == true) {
console.warn("entities/linked endpoint is deprecated and has been combined with entities. No need to specify linked parameter.");
var urlParts = URL.parse(serviceURL + "entities/linked");
} else {
urlParts = URL.parse(serviceURL + "entities");
}

var urlParts = URL.parse(serviceURL + "entities");

var req = new rosetteRequest();
req.makeRequest('POST', userKey, protocol, urlParts, parameters, callback);
Expand Down
25 changes: 20 additions & 5 deletions lib/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var http = require("http");
var https = require("https");
var zlib = require("zlib");

var querystring = require('querystring');

/**
* Compatible server version.
*
Expand Down Expand Up @@ -63,9 +65,6 @@ function parameters() {
this.options = null;
this.accuracyMode = null;

//entities parameters
this.linked = null;

//sentiment parameters
this.explain = null;
this.shortString = null;
Expand All @@ -76,6 +75,9 @@ function parameters() {
//headers
this.customHeaders = null;

//URL parameters
this.urlParameters = null;

}

/**
Expand All @@ -102,7 +104,8 @@ parameters.prototype.loadParams = function() {
"options": this.options,
"explain": this.explain,
"short-string": this.shortString,
"_customHeaders": this.customHeaders
"_customHeaders": this.customHeaders,
"_urlParameters": this.urlParameters
};

for (var key in paramJSON) {
Expand Down Expand Up @@ -155,11 +158,23 @@ parameters.prototype.loadFile = function(filePath, loadedParameters, userKey, pr
}
headers["X-RosetteAPI-Key"] = userKey;

if (parameters.customHeaders != null) {
parameters.customHeaders.forEach(function(element, index) {
headers[element[0]] = element[1];
});
}

var path = urlParts.path;

if (parameters.urlParameters != null) {
path = path + '?' + querystring.stringify(parameters.urlParameters);
}

var result = new Buffer("");

var options = {
hostname: urlParts.hostname,
path: urlParts.path,
path: path,
method: 'POST',
headers: headers,
agent: false
Expand Down
12 changes: 10 additions & 2 deletions lib/rosetteRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ var zlib = require("zlib");
var rosetteConstants = require("./rosetteConstants");
var RosetteException = require("./rosetteExceptions");

var querystring = require('querystring');

/**
* Compatible server version.
*
* @type string
*/
var BINDING_VERSION = "1.4.0";
var BINDING_VERSION = "1.5.0";

/**
* @class
Expand Down Expand Up @@ -69,9 +71,15 @@ rosetteRequest.prototype.makeRequest = function(requestType, userKey, protocol,

}

var path = urlParts.path;

if (parameters.urlParameters != null) {
path = path + '?' + querystring.stringify(parameters.urlParameters);
}

var options = {
hostname: urlParts.hostname,
path: urlParts.path,
path: path,
method: requestType,
headers: headers,
agent: false
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": "rosette-api",
"version": "1.4.0",
"version": "1.5.0",
"description": "Rosette API Node.js client SDK",
"main": "index",
"directories": {
Expand Down

0 comments on commit 98c2be3

Please sign in to comment.