Skip to content

Commit 8e5ca3e

Browse files
committed
Merge pull request watson-developer-cloud#252 from watson-developer-cloud/visual-recognition
Visual recognition v3
2 parents bd50b8f + c8c84a9 commit 8e5ca3e

File tree

9 files changed

+991
-215
lines changed

9 files changed

+991
-215
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ script:
1010
after_success:
1111
- jsdoc/publish.sh
1212
before_install:
13-
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_d4f181ef7c79_key
14-
-iv $encrypted_d4f181ef7c79_iv -in auth.js.enc -out test/resources/auth.js -d ||
15-
true'
13+
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_cb4d3d070e32_key -iv $encrypted_cb4d3d070e32_iv -in auth.js.enc -out test/resources/auth.js -d || true'
1614
env:
1715
global:
1816
secure: I50FnfubwiZlol5Qs9tXPVACGbs+SG2dJLjpbzeio0Hl666d/hDuvf7IFwqqaRjQkmK2TdIjaGLMOgHxh/GGAoYf7LfZqjDID/tAhgoFOYiZwiPj66Z82F9P9cega2nkNW+125NzPuU3rhSCByG8+K/PMH/5JxPwPMoAYNLQjWc=

auth.js.enc

144 Bytes
Binary file not shown.

lib/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function createServiceAPI(serviceName) {
4040
return function(user_options) {
4141
var options = extend({}, user_options);
4242
var alchemy = (serviceName.indexOf('alchemy_') === 0);
43+
var vrv3 = (serviceName === 'visual_recognition' && user_options.version === 'v3');
4344

4445
// For Alchemy we use 'v1' by default,
4546
// and check if `apikey` was specified.
@@ -48,6 +49,9 @@ function createServiceAPI(serviceName) {
4849
options.alchemy = true;
4950
options.version = 'v1';
5051
options.api_key = options.apikey || options.api_key;
52+
} else if (vrv3) {
53+
// Visual Recognition v3 similarly uses an API key instead of username + password
54+
options.api_key = options.apikey || options.api_key;
5155
} else {
5256
options.jar = request.jar();
5357
}
@@ -76,7 +80,7 @@ function createServiceAPI(serviceName) {
7680
// Check if 'api_key' or 'username' and 'password' were provided
7781
if (typeof api_key === 'undefined') {
7882
if (typeof user === 'undefined' || typeof pass === 'undefined') {
79-
if (alchemy)
83+
if (alchemy || vrv3)
8084
throw new Error('Argument error: api_key was not specified');
8185
else
8286
throw new Error('Argument error: api_key or username and password were not specified');
@@ -150,7 +154,7 @@ var watson = {
150154
/**
151155
* @function
152156
* @param {{}} options
153-
* @returns {VisualRecognitionV1Beta|VisualRecognitionV2Beta}
157+
* @returns {VisualRecognitionV1Beta|VisualRecognitionV2Beta|VisualRecognitionV3}
154158
*/
155159
visual_recognition: createServiceAPI('visual_recognition'),
156160

@@ -275,7 +279,7 @@ var watson = {
275279
* @returns {AlchemyDataNews}
276280
*/
277281
alchemy_data_news: createServiceAPI('alchemy_data_news'),
278-
282+
279283
/**
280284
* @function
281285
* @param {{}} options

lib/requestwrapper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function formatErrorIfExists(cb) {
7676
* 3. Encode path and query parameters
7777
* 4. Call the api
7878
* @private
79+
* @return {ReadableStream|undefined}
7980
*/
8081
function createRequest(parameters, callback) {
8182
var missingParams = null,

services/visual_recognition/v1-beta.js

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)