{"action":"created","comment":{"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments/65028504","id":65028504,"diff_hunk":"@@ -0,0 +1,163 @@\n+/**\n+ * Copyright 2013,2016 IBM Corp.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ **/\n+\n+module.exports = function (RED) {\n+  var watson = require('watson-developer-cloud');  \n+  var cfenv = require('cfenv');\n+\n+  // Require the Cloud Foundry Module to pull credentials from bound service \n+  // If they are found then they are stored in sUsername and sPassword, as the \n+  // service credentials. This separation from sUsername and username to allow \n+  // the end user to modify the node credentials when the service is not bound.\n+  // Otherwise, once set username would never get reset, resulting in a frustrated\n+  // user who, when he errenously enters bad credentials, can't figure out why\n+  // the edited ones are not being taken.\n+\n+  // Not ever used, and codeacy complains about it.\n+\n+  var username, password, sUsername, sPassword;\n+\n+  var service = cfenv.getAppEnv().getServiceCreds(/tone analyzer/i)\n+\n+  if (service) {\n+    sUsername = service.username;\n+    sPassword = service.password;\n+  }\n+\n+  // Node RED Admin - fetch and set vcap services\n+  RED.httpAdmin.get('/watson-tone-analyzer/vcap', function (req, res) {\n+    res.json(service ? {bound_service: true} : null);\n+  });\n+\n+  // Function that checks the payload and determines\n+  // whether it is JSON or a Buffer\n+  var checkPayload = function(payload) {\n+    var message = null;\n+\n+    var hasJSONmethod = (typeof payload.toJSON === 'function') ;\n+      if (hasJSONmethod === true) {\n+        if (payload.toJSON().type === 'Buffer') {\n+          isBuffer = true;\n+        }      \n+      }      \n+      // Payload (text to be analysed) must be a string (content is either raw string or Buffer)\n+      if (typeof payload !== 'string' &&  isBuffer !== true) {","path":"services/tone_analyzer/v3.js","position":57,"original_position":57,"commit_id":"c5c4bfd96d1de6e16a549c902b5e0bf39649157d","original_commit_id":"c5c4bfd96d1de6e16a549c902b5e0bf39649157d","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 indentation of 4 space characters but found 6.](https://www.codacy.com/app/rezgui-y/node-red-node-watson/file/2653030321/issues/source?bid=3225115&fileBranchId=3325196#l57)","created_at":"2016-05-30T06:28:58Z","updated_at":"2016-05-30T06:28:58Z","html_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/96#discussion_r65028504","pull_request_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/96","_links":{"self":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/comments/65028504"},"html":{"href":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/96#discussion_r65028504"},"pull_request":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/96"}}},"pull_request":{"url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/96","id":71840307,"html_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/96","diff_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/96.diff","patch_url":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/96.patch","issue_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/96","number":96,"state":"open","locked":false,"title":"New Tone Analzer node for V3 GA API","user":{"login":"chughts","id":10371360,"avatar_url":"https://avatars.githubusercontent.com/u/10371360?v=3","gravatar_id":"","url":"https://api.github.com/users/chughts","html_url":"https://github.com/chughts","followers_url":"https://api.github.com/users/chughts/followers","following_url":"https://api.github.com/users/chughts/following{/other_user}","gists_url":"https://api.github.com/users/chughts/gists{/gist_id}","starred_url":"https://api.github.com/users/chughts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chughts/subscriptions","organizations_url":"https://api.github.com/users/chughts/orgs","repos_url":"https://api.github.com/users/chughts/repos","events_url":"https://api.github.com/users/chughts/events{/privacy}","received_events_url":"https://api.github.com/users/chughts/received_events","type":"User","site_admin":false},"body":"A new Tone Analyzer node developed to support the newly GA version of the API. The old V3 beta node has been retained for backward compatibility so that any existing flows with valid (old credentials) are not broken.\r\nThe package pre-reqs have been updated to the the level of the watson-developer-cloud SDK that provides support for the GA Tone Analyser API (1.9.2)","created_at":"2016-05-29T22:54:18Z","updated_at":"2016-05-30T06:28:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bab5da738d451a087e912e1aba4f40a84db34d41","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/96/commits","review_comments_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/96/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/96/comments","statuses_url":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/c5c4bfd96d1de6e16a549c902b5e0bf39649157d","head":{"label":"chughts:master","ref":"master","sha":"c5c4bfd96d1de6e16a549c902b5e0bf39649157d","user":{"login":"chughts","id":10371360,"avatar_url":"https://avatars.githubusercontent.com/u/10371360?v=3","gravatar_id":"","url":"https://api.github.com/users/chughts","html_url":"https://github.com/chughts","followers_url":"https://api.github.com/users/chughts/followers","following_url":"https://api.github.com/users/chughts/following{/other_user}","gists_url":"https://api.github.com/users/chughts/gists{/gist_id}","starred_url":"https://api.github.com/users/chughts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chughts/subscriptions","organizations_url":"https://api.github.com/users/chughts/orgs","repos_url":"https://api.github.com/users/chughts/repos","events_url":"https://api.github.com/users/chughts/events{/privacy}","received_events_url":"https://api.github.com/users/chughts/received_events","type":"User","site_admin":false},"repo":{"id":58115630,"name":"node-red-node-watson","full_name":"chughts/node-red-node-watson","owner":{"login":"chughts","id":10371360,"avatar_url":"https://avatars.githubusercontent.com/u/10371360?v=3","gravatar_id":"","url":"https://api.github.com/users/chughts","html_url":"https://github.com/chughts","followers_url":"https://api.github.com/users/chughts/followers","following_url":"https://api.github.com/users/chughts/following{/other_user}","gists_url":"https://api.github.com/users/chughts/gists{/gist_id}","starred_url":"https://api.github.com/users/chughts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chughts/subscriptions","organizations_url":"https://api.github.com/users/chughts/orgs","repos_url":"https://api.github.com/users/chughts/repos","events_url":"https://api.github.com/users/chughts/events{/privacy}","received_events_url":"https://api.github.com/users/chughts/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chughts/node-red-node-watson","description":"A collection of nodes for the IBM Watson services","fork":true,"url":"https://api.github.com/repos/chughts/node-red-node-watson","forks_url":"https://api.github.com/repos/chughts/node-red-node-watson/forks","keys_url":"https://api.github.com/repos/chughts/node-red-node-watson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chughts/node-red-node-watson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chughts/node-red-node-watson/teams","hooks_url":"https://api.github.com/repos/chughts/node-red-node-watson/hooks","issue_events_url":"https://api.github.com/repos/chughts/node-red-node-watson/issues/events{/number}","events_url":"https://api.github.com/repos/chughts/node-red-node-watson/events","assignees_url":"https://api.github.com/repos/chughts/node-red-node-watson/assignees{/user}","branches_url":"https://api.github.com/repos/chughts/node-red-node-watson/branches{/branch}","tags_url":"https://api.github.com/repos/chughts/node-red-node-watson/tags","blobs_url":"https://api.github.com/repos/chughts/node-red-node-watson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chughts/node-red-node-watson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chughts/node-red-node-watson/git/refs{/sha}","trees_url":"https://api.github.com/repos/chughts/node-red-node-watson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chughts/node-red-node-watson/statuses/{sha}","languages_url":"https://api.github.com/repos/chughts/node-red-node-watson/languages","stargazers_url":"https://api.github.com/repos/chughts/node-red-node-watson/stargazers","contributors_url":"https://api.github.com/repos/chughts/node-red-node-watson/contributors","subscribers_url":"https://api.github.com/repos/chughts/node-red-node-watson/subscribers","subscription_url":"https://api.github.com/repos/chughts/node-red-node-watson/subscription","commits_url":"https://api.github.com/repos/chughts/node-red-node-watson/commits{/sha}","git_commits_url":"https://api.github.com/repos/chughts/node-red-node-watson/git/commits{/sha}","comments_url":"https://api.github.com/repos/chughts/node-red-node-watson/comments{/number}","issue_comment_url":"https://api.github.com/repos/chughts/node-red-node-watson/issues/comments{/number}","contents_url":"https://api.github.com/repos/chughts/node-red-node-watson/contents/{+path}","compare_url":"https://api.github.com/repos/chughts/node-red-node-watson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chughts/node-red-node-watson/merges","archive_url":"https://api.github.com/repos/chughts/node-red-node-watson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chughts/node-red-node-watson/downloads","issues_url":"https://api.github.com/repos/chughts/node-red-node-watson/issues{/number}","pulls_url":"https://api.github.com/repos/chughts/node-red-node-watson/pulls{/number}","milestones_url":"https://api.github.com/repos/chughts/node-red-node-watson/milestones{/number}","notifications_url":"https://api.github.com/repos/chughts/node-red-node-watson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chughts/node-red-node-watson/labels{/name}","releases_url":"https://api.github.com/repos/chughts/node-red-node-watson/releases{/id}","deployments_url":"https://api.github.com/repos/chughts/node-red-node-watson/deployments","created_at":"2016-05-05T08:19:28Z","updated_at":"2016-05-14T07:16:53Z","pushed_at":"2016-05-30T06:27:26Z","git_url":"git://github.com/chughts/node-red-node-watson.git","ssh_url":"git@github.com:chughts/node-red-node-watson.git","clone_url":"https://github.com/chughts/node-red-node-watson.git","svn_url":"https://github.com/chughts/node-red-node-watson","homepage":null,"size":7769,"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":"001821ba9f1b43061389d162bd3c67577fd2715b","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-05-29T06:53:07Z","pushed_at":"2016-05-30T06:27:26Z","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":7833,"stargazers_count":7,"watchers_count":7,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":7,"forks":13,"open_issues":7,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/96"},"html":{"href":"https://github.com/watson-developer-cloud/node-red-node-watson/pull/96"},"issue":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/96"},"comments":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/issues/96/comments"},"review_comments":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/pulls/96/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/96/commits"},"statuses":{"href":"https://api.github.com/repos/watson-developer-cloud/node-red-node-watson/statuses/c5c4bfd96d1de6e16a549c902b5e0bf39649157d"}}}}
{"actor":{"display_login":"yrezgui"}}