Skip to content

Commit 0c2cebe

Browse files
committed
[DCS] Makes default version_date a static value
We decided to make the default version date a static value for the experimental service. This also allows us to remove the dependency on moment. This commit also changes how the version date is expected to be passed in, moving it to a top-level option to be consistent with the Visual Recognition v2-beta API.
1 parent 3ca894d commit 0c2cebe

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@ var watson = require('watson-developer-cloud');
294294
var fs = require('fs');
295295

296296
var document_conversion = watson.document_conversion({
297-
username: '<username>',
298-
password: '<password>',
299-
version: 'v1-experimental',
300-
qs: { version: '2015-12-01' }
297+
username: '<username>',
298+
password: '<password>',
299+
version: 'v1-experimental',
300+
version_date: '2015-12-01'
301301
});
302302

303303
// convert a single document

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
"csv-stringify": "~0.0.8",
7373
"extend": "~3.0.0",
7474
"isstream": "~0.1.2",
75-
"moment": "~2.10.6",
7675
"object.omit": "~2.0.0",
7776
"object.pick": "~1.1.1",
7877
"request": "~2.67.0",

services/document_conversion/v1-experimental.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,23 @@ var extend = require('extend');
2020
var requestFactory = require('../../lib/requestwrapper');
2121
var isStream = require('isstream');
2222
var omit = require('object.omit');
23-
var moment = require('moment');
2423

2524
function DocumentConversion(options) {
25+
// Warn if not specifying version date
26+
var version_date = "2015-12-01"
27+
if(options && options.version_date) {
28+
version_date = options.version_date
29+
} else {
30+
console.warn("[DocumentConversion] WARNING: No version_date specified. Using a (possibly old) default. " +
31+
"e.g. watson.document_conversion({ version_date: '2015-12-01' })")
32+
}
33+
2634
// Default URL
2735
var serviceDefaults = {
2836
url: 'https://gateway.watsonplatform.net/document-conversion-experimental/api',
29-
qs: { version: moment.utc().subtract(1, 'd').format('YYYY-MM-DD') }
37+
qs: { version: version_date }
3038
};
3139

32-
// Warn if not specifying version date
33-
if(!options || !options.qs || !options.qs.version) {
34-
console.warn("[DocumentConversion] WARNING: Not specifying a version query parameter may result in code instability. " +
35-
"e.g. watson.document_conversion({ qs: { version: '2015-12-01' } })")
36-
}
37-
3840
// Replace default options with user provided
3941
this._options = extend(serviceDefaults, options);
4042
}

test/test.document_conversion.v1-experimental.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('document_conversion', function() {
9191
});
9292

9393
it('should allow the version query param to be overridden', function() {
94-
var custServInstance = watson.document_conversion(extend(service_options, { qs: { version: "2015-11-30"} }));
94+
var custServInstance = watson.document_conversion(extend(service_options, { version_date: "2015-11-30"}));
9595
var req = custServInstance.convert(payload, noop);
9696
assert(req.uri.query.indexOf("version=2015-11-30" > -1));
9797
});

0 commit comments

Comments
 (0)