{"action":"created","comment":{"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments/59535683","id":59535683,"diff_hunk":"@@ -13,55 +13,207 @@\n  * See the License for the specific language governing permissions and\n  * limitations under the License.\n  **/\n-\n-module.exports = function(RED) {\n+module.exports = function (RED) {\n   var watson = require('watson-developer-cloud');\n   var cfenv = require('cfenv');\n+  var fs = require('fs');\n+  var temp = require('temp');\n \n-  var services = cfenv.getAppEnv().services,\n-    service;\n+  temp.track();\n \n-  var username, password;\n+  var username, password, language_translation;\n \n-  var service = cfenv.getAppEnv().getServiceCreds(/language translation/i)\n+  var service = cfenv.getAppEnv().getServiceCreds(/language translation/i);\n \n   if (service) {\n     username = service.username;\n     password = service.password;\n   }\n- \n-  RED.httpAdmin.get('/watson-translate/vcap', function(req, res) {\n-    res.json(service ? {bound_service: true} : null);\n+\n+  RED.httpAdmin.get('/watson-translate/vcap', function (req, res) {\n+    res.json(service ? {\n+      bound_service: true\n+    } : null);\n+  });\n+\n+  RED.httpAdmin.get('/watson-translate/models', function (req, res) {\n+    language_translation = watson.language_translation({\n+      username: username,\n+      password: password,\n+      version: 'v2'\n+    });\n+    language_translation.getModels({}, function (err, models) {\n+      if (err) {\n+        res.json(err);\n+      }\n+      else {\n+        res.json(models);\n+      }\n+    });\n+  });\n+\n+  RED.httpAdmin.get('/watson-translate/languages', function (req, res) {\n+    language_translation = watson.language_translation({\n+      username: username,\n+      password: password,\n+      version: 'v2'\n+    });\n+    language_translation.getIdentifiableLanguages(null,\n+      function (err, languages) {\n+        if (err) {\n+          res.json(err);\n+        }\n+        else {\n+          res.json(languages);\n+        }\n+      });\n   });\n \n   function SMTNode(config) {\n     RED.nodes.createNode(this, config);\n     var node = this;\n \n-    this.on('input', function(msg) {\n+    this.doTranslate = function (msg, model_id) {\n+      language_translation = watson.language_translation({\n+        username: username,\n+        password: password,\n+        version: 'v2'\n+      });\n+\n+      node.status({\n+        fill: 'blue',\n+        shape: 'dot',\n+        text: 'requesting'\n+      });\n+      language_translation.translate({\n+        text: msg.payload,","path":"services/language_translation/v1.js","position":94,"original_position":94,"commit_id":"306c1303ded31b25bb3e77015b5dc2a9717a7dea","original_commit_id":"306c1303ded31b25bb3e77015b5dc2a9717a7dea","user":{"login":"yrezgui","id":1113976,"avatar_url":"https://avatars.githubusercontent.com/u/1113976?v=3","gravatar_id":"","url":"https://api.github.com/users/yrezgui","html_url":"https://github.com/yrezgui","followers_url":"https://api.github.com/users/yrezgui/followers","following_url":"https://api.github.com/users/yrezgui/following{/other_user}","gists_url":"https://api.github.com/users/yrezgui/gists{/gist_id}","starred_url":"https://api.github.com/users/yrezgui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yrezgui/subscriptions","organizations_url":"https://api.github.com/users/yrezgui/orgs","repos_url":"https://api.github.com/users/yrezgui/repos","events_url":"https://api.github.com/users/yrezgui/events{/privacy}","received_events_url":"https://api.github.com/users/yrezgui/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/assets/images/favicon.png) Issue found: [Expected property shorthand.](https://www.codacy.com/app/rezgui-y/node-red-node-watson/file/2399725591/issues/source?bid=3225115&fileBranchId=3231190#l90)","created_at":"2016-04-13T12:03:33Z","updated_at":"2016-04-13T12:03:33Z","html_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/28#discussion_r59535683","pull_request_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments/59535683"},"html":{"href":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/28#discussion_r59535683"},"pull_request":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/28","id":66240120,"html_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/28","diff_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/28.diff","patch_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/28.patch","issue_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/28","number":28,"state":"open","locked":false,"title":"new STT and language translation nodes","user":{"login":"arlemi","id":5029719,"avatar_url":"https://avatars.githubusercontent.com/u/5029719?v=3","gravatar_id":"","url":"https://api.github.com/users/arlemi","html_url":"https://github.com/arlemi","followers_url":"https://api.github.com/users/arlemi/followers","following_url":"https://api.github.com/users/arlemi/following{/other_user}","gists_url":"https://api.github.com/users/arlemi/gists{/gist_id}","starred_url":"https://api.github.com/users/arlemi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arlemi/subscriptions","organizations_url":"https://api.github.com/users/arlemi/orgs","repos_url":"https://api.github.com/users/arlemi/repos","events_url":"https://api.github.com/users/arlemi/events{/privacy}","received_events_url":"https://api.github.com/users/arlemi/received_events","type":"User","site_admin":false},"body":"There seems to be a few conflicts, need to check before merging. ","created_at":"2016-04-12T22:41:20Z","updated_at":"2016-04-13T12:03:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/28/commits","review_comments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/28/comments","review_comment_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments{/number}","comments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/28/comments","statuses_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/306c1303ded31b25bb3e77015b5dc2a9717a7dea","head":{"label":"arlemi:master","ref":"master","sha":"306c1303ded31b25bb3e77015b5dc2a9717a7dea","user":{"login":"arlemi","id":5029719,"avatar_url":"https://avatars.githubusercontent.com/u/5029719?v=3","gravatar_id":"","url":"https://api.github.com/users/arlemi","html_url":"https://github.com/arlemi","followers_url":"https://api.github.com/users/arlemi/followers","following_url":"https://api.github.com/users/arlemi/following{/other_user}","gists_url":"https://api.github.com/users/arlemi/gists{/gist_id}","starred_url":"https://api.github.com/users/arlemi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arlemi/subscriptions","organizations_url":"https://api.github.com/users/arlemi/orgs","repos_url":"https://api.github.com/users/arlemi/repos","events_url":"https://api.github.com/users/arlemi/events{/privacy}","received_events_url":"https://api.github.com/users/arlemi/received_events","type":"User","site_admin":false},"repo":{"id":56012865,"name":"node-red-node-watson","full_name":"arlemi/node-red-node-watson","owner":{"login":"arlemi","id":5029719,"avatar_url":"https://avatars.githubusercontent.com/u/5029719?v=3","gravatar_id":"","url":"https://api.github.com/users/arlemi","html_url":"https://github.com/arlemi","followers_url":"https://api.github.com/users/arlemi/followers","following_url":"https://api.github.com/users/arlemi/following{/other_user}","gists_url":"https://api.github.com/users/arlemi/gists{/gist_id}","starred_url":"https://api.github.com/users/arlemi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arlemi/subscriptions","organizations_url":"https://api.github.com/users/arlemi/orgs","repos_url":"https://api.github.com/users/arlemi/repos","events_url":"https://api.github.com/users/arlemi/events{/privacy}","received_events_url":"https://api.github.com/users/arlemi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/arlemi/node-red-node-watson","description":"A collection of nodes for the IBM Watson services","fork":true,"url":"https://api.github.com/repos/arlemi/node-red-node-watson","forks_url":"https://api.github.com/repos/arlemi/node-red-node-watson/forks","keys_url":"https://api.github.com/repos/arlemi/node-red-node-watson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arlemi/node-red-node-watson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arlemi/node-red-node-watson/teams","hooks_url":"https://api.github.com/repos/arlemi/node-red-node-watson/hooks","issue_events_url":"https://api.github.com/repos/arlemi/node-red-node-watson/issues/events{/number}","events_url":"https://api.github.com/repos/arlemi/node-red-node-watson/events","assignees_url":"https://api.github.com/repos/arlemi/node-red-node-watson/assignees{/user}","branches_url":"https://api.github.com/repos/arlemi/node-red-node-watson/branches{/branch}","tags_url":"https://api.github.com/repos/arlemi/node-red-node-watson/tags","blobs_url":"https://api.github.com/repos/arlemi/node-red-node-watson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arlemi/node-red-node-watson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arlemi/node-red-node-watson/git/refs{/sha}","trees_url":"https://api.github.com/repos/arlemi/node-red-node-watson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arlemi/node-red-node-watson/statuses/{sha}","languages_url":"https://api.github.com/repos/arlemi/node-red-node-watson/languages","stargazers_url":"https://api.github.com/repos/arlemi/node-red-node-watson/stargazers","contributors_url":"https://api.github.com/repos/arlemi/node-red-node-watson/contributors","subscribers_url":"https://api.github.com/repos/arlemi/node-red-node-watson/subscribers","subscription_url":"https://api.github.com/repos/arlemi/node-red-node-watson/subscription","commits_url":"https://api.github.com/repos/arlemi/node-red-node-watson/commits{/sha}","git_commits_url":"https://api.github.com/repos/arlemi/node-red-node-watson/git/commits{/sha}","comments_url":"https://api.github.com/repos/arlemi/node-red-node-watson/comments{/number}","issue_comment_url":"https://api.github.com/repos/arlemi/node-red-node-watson/issues/comments{/number}","contents_url":"https://api.github.com/repos/arlemi/node-red-node-watson/contents/{+path}","compare_url":"https://api.github.com/repos/arlemi/node-red-node-watson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arlemi/node-red-node-watson/merges","archive_url":"https://api.github.com/repos/arlemi/node-red-node-watson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arlemi/node-red-node-watson/downloads","issues_url":"https://api.github.com/repos/arlemi/node-red-node-watson/issues{/number}","pulls_url":"https://api.github.com/repos/arlemi/node-red-node-watson/pulls{/number}","milestones_url":"https://api.github.com/repos/arlemi/node-red-node-watson/milestones{/number}","notifications_url":"https://api.github.com/repos/arlemi/node-red-node-watson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arlemi/node-red-node-watson/labels{/name}","releases_url":"https://api.github.com/repos/arlemi/node-red-node-watson/releases{/id}","deployments_url":"https://api.github.com/repos/arlemi/node-red-node-watson/deployments","created_at":"2016-04-11T22:35:46Z","updated_at":"2016-04-11T22:35:48Z","pushed_at":"2016-04-13T12:01:42Z","git_url":"git://github.com/arlemi/node-red-node-watson.git","ssh_url":"git@github.com:arlemi/node-red-node-watson.git","clone_url":"https://github.com/arlemi/node-red-node-watson.git","svn_url":"https://github.com/arlemi/node-red-node-watson","homepage":null,"size":7597,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"watson-developer-cloud:master","ref":"master","sha":"fd266990d2098c5d5461bac843ec992fc222f62f","user":{"login":"watson-developer-cloud","id":10017763,"avatar_url":"https://avatars.githubusercontent.com/u/10017763?v=3","gravatar_id":"","url":"https://api.github.com/users/watson-developer-cloud","html_url":"https://github.com/watson-developer-cloud","followers_url":"https://api.github.com/users/watson-developer-cloud/followers","following_url":"https://api.github.com/users/watson-developer-cloud/following{/other_user}","gists_url":"https://api.github.com/users/watson-developer-cloud/gists{/gist_id}","starred_url":"https://api.github.com/users/watson-developer-cloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watson-developer-cloud/subscriptions","organizations_url":"https://api.github.com/users/watson-developer-cloud/orgs","repos_url":"https://api.github.com/users/watson-developer-cloud/repos","events_url":"https://api.github.com/users/watson-developer-cloud/events{/privacy}","received_events_url":"https://api.github.com/users/watson-developer-cloud/received_events","type":"Organization","site_admin":false},"repo":{"id":55415107,"name":"node-red-node-watson","full_name":"watson-developer-cloud/node-red-node-watson","owner":{"login":"watson-developer-cloud","id":10017763,"avatar_url":"https://avatars.githubusercontent.com/u/10017763?v=3","gravatar_id":"","url":"https://api.github.com/users/watson-developer-cloud","html_url":"https://github.com/watson-developer-cloud","followers_url":"https://api.github.com/users/watson-developer-cloud/followers","following_url":"https://api.github.com/users/watson-developer-cloud/following{/other_user}","gists_url":"https://api.github.com/users/watson-developer-cloud/gists{/gist_id}","starred_url":"https://api.github.com/users/watson-developer-cloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watson-developer-cloud/subscriptions","organizations_url":"https://api.github.com/users/watson-developer-cloud/orgs","repos_url":"https://api.github.com/users/watson-developer-cloud/repos","events_url":"https://api.github.com/users/watson-developer-cloud/events{/privacy}","received_events_url":"https://api.github.com/users/watson-developer-cloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/watson-developer-cloud/node-red-node-watson","description":"A collection of nodes for the IBM Watson services","fork":true,"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson","forks_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/forks","keys_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/teams","hooks_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/hooks","issue_events_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/events{/number}","events_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/events","assignees_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/assignees{/user}","branches_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/branches{/branch}","tags_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/tags","blobs_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/refs{/sha}","trees_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/{sha}","languages_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/languages","stargazers_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/stargazers","contributors_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/contributors","subscribers_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/subscribers","subscription_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/subscription","commits_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/commits{/sha}","git_commits_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/git/commits{/sha}","comments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/comments{/number}","issue_comment_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/comments{/number}","contents_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/contents/{+path}","compare_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/merges","archive_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/downloads","issues_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues{/number}","pulls_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls{/number}","milestones_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/milestones{/number}","notifications_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/labels{/name}","releases_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/releases{/id}","deployments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/deployments","created_at":"2016-04-04T13:51:28Z","updated_at":"2016-04-11T13:49:32Z","pushed_at":"2016-04-13T12:01:43Z","git_url":"git://github.com/watson-developer-cloud/node-red-node-watson.git","ssh_url":"git@github.com:watson-developer-cloud/node-red-node-watson.git","clone_url":"https://github.com/watson-developer-cloud/node-red-node-watson.git","svn_url":"https://github.com/watson-developer-cloud/node-red-node-watson","homepage":null,"size":7852,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":1,"forks":6,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/28"},"html":{"href":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/28"},"issue":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/28"},"comments":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/306c1303ded31b25bb3e77015b5dc2a9717a7dea"}}}}