{"action":"created","comment":{"url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/comments/61559271","id":61559271,"diff_hunk":"@@ -0,0 +1,138 @@\n+var AccountingService = require('./../../db/schemas/accountingService'),\n+    async = require('async'),\n+    storeClient = require('./../../lib/store').storeClient,\n+    utils = require('./../../lib/utils');\n+\n+var usageManagement = ( function () {\n+\n+    /**\n+     * Check if the API Key passed is a valid API Key\n+     *\n+     * @param  {Object}   req      Incoming request.\n+     */\n+    var validateApiKey = function (req, callback) {\n+\n+        var apiKey = req.get('X-API-KEY');\n+\n+        if (!apiKey) {\n+\n+            return callback({\n+                status: 401,\n+                message: 'Missing header \"X-API-KEY\"'\n+            });\n+\n+        } else {\n+\n+            AccountingService.findOne( {apiKey: apiKey}, function (err, result) {\n+\n+                if (err) {\n+\n+                    return callback({\n+                        status: 500,\n+                        message: 'Error validating apiKey'\n+                    });\n+\n+                } else if (!result) {\n+\n+                    return callback({\n+                        status: 401,\n+                        message: 'Invalid apikey'\n+                    });\n+\n+                } else if (result.state !== 'COMMITTED') {\n+\n+                    return callback({\n+                        status: 401,\n+                        message: 'Apikey uncommitted'\n+                    });\n+\n+                } else {\n+                    return callback();\n+                }\n+            });\n+        }\n+    };\n+\n+    /**\n+     * Assigns the user id to the relatedPaty query string if it is not defined.\n+     *\n+     * @param  {Object}   req      Incoming request\n+     */\n+    var validateRetrieving = function (req, callback) {\n+\n+        var userId = req.user.id;\n+\n+        if (!req.query.relatedParty) {\n+\n+            req.query.relatedParty = {","path":"controllers/tmf-apis/usageManagement.js","position":67,"original_position":67,"commit_id":"d4aec35bc5f540abe359f917b05847110c42f5aa","original_commit_id":"d4aec35bc5f540abe359f917b05847110c42f5aa","user":{"login":"aitormagan","id":2526562,"avatar_url":"https://avatars.githubusercontent.com/u/2526562?v=3","gravatar_id":"","url":"https://api.github.com/users/aitormagan","html_url":"https://github.com/aitormagan","followers_url":"https://api.github.com/users/aitormagan/followers","following_url":"https://api.github.com/users/aitormagan/following{/other_user}","gists_url":"https://api.github.com/users/aitormagan/gists{/gist_id}","starred_url":"https://api.github.com/users/aitormagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aitormagan/subscriptions","organizations_url":"https://api.github.com/users/aitormagan/orgs","repos_url":"https://api.github.com/users/aitormagan/repos","events_url":"https://api.github.com/users/aitormagan/events{/privacy}","received_events_url":"https://api.github.com/users/aitormagan/received_events","type":"User","site_admin":false},"body":"This won't work. You are trying to include a query parameter in the request that is done to the final API but it won't be included because the implemented logic in `tmf.js` does not work in this way. You have two options:\r\n\r\n* Modify `tmf.js` so the final query string is formed based on `req.query`. This will imply modifying some controllers (recommended).\r\n* Modify `apiUrl` manually to include the new query param. This is the way we have been using until now. You can take advantage of the function `filterRelatedPartyFields` in `lib/tmfUtils.js` that does this work for you! :)","created_at":"2016-04-29T10:33:06Z","updated_at":"2016-04-29T10:33:06Z","html_url":"https://github.com/FIWARE-TMForum/business-ecosystem-logic-proxy/pull/66#discussion_r61559271","pull_request_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/66","_links":{"self":{"href":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/comments/61559271"},"html":{"href":"https://github.com/FIWARE-TMForum/business-ecosystem-logic-proxy/pull/66#discussion_r61559271"},"pull_request":{"href":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/66"}}},"pull_request":{"url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/66","id":67004389,"html_url":"https://github.com/FIWARE-TMForum/business-ecosystem-logic-proxy/pull/66","diff_url":"https://github.com/FIWARE-TMForum/business-ecosystem-logic-proxy/pull/66.diff","patch_url":"https://github.com/FIWARE-TMForum/business-ecosystem-logic-proxy/pull/66.patch","issue_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/issues/66","number":66,"state":"open","locked":false,"title":"Add new controller for authorize service","user":{"login":"vramperez","id":16591014,"avatar_url":"https://avatars.githubusercontent.com/u/16591014?v=3","gravatar_id":"","url":"https://api.github.com/users/vramperez","html_url":"https://github.com/vramperez","followers_url":"https://api.github.com/users/vramperez/followers","following_url":"https://api.github.com/users/vramperez/following{/other_user}","gists_url":"https://api.github.com/users/vramperez/gists{/gist_id}","starred_url":"https://api.github.com/users/vramperez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vramperez/subscriptions","organizations_url":"https://api.github.com/users/vramperez/orgs","repos_url":"https://api.github.com/users/vramperez/repos","events_url":"https://api.github.com/users/vramperez/events{/privacy}","received_events_url":"https://api.github.com/users/vramperez/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-19T11:48:51Z","updated_at":"2016-04-29T10:33:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa077c54c223877022d57092d4533466bc84cd02","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/66/commits","review_comments_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/66/comments","review_comment_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/issues/66/comments","statuses_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/statuses/d4aec35bc5f540abe359f917b05847110c42f5aa","head":{"label":"vramperez:feature/usage-integration","ref":"feature/usage-integration","sha":"d4aec35bc5f540abe359f917b05847110c42f5aa","user":{"login":"vramperez","id":16591014,"avatar_url":"https://avatars.githubusercontent.com/u/16591014?v=3","gravatar_id":"","url":"https://api.github.com/users/vramperez","html_url":"https://github.com/vramperez","followers_url":"https://api.github.com/users/vramperez/followers","following_url":"https://api.github.com/users/vramperez/following{/other_user}","gists_url":"https://api.github.com/users/vramperez/gists{/gist_id}","starred_url":"https://api.github.com/users/vramperez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vramperez/subscriptions","organizations_url":"https://api.github.com/users/vramperez/orgs","repos_url":"https://api.github.com/users/vramperez/repos","events_url":"https://api.github.com/users/vramperez/events{/privacy}","received_events_url":"https://api.github.com/users/vramperez/received_events","type":"User","site_admin":false},"repo":{"id":56500699,"name":"business-ecosystem-logic-proxy","full_name":"vramperez/business-ecosystem-logic-proxy","owner":{"login":"vramperez","id":16591014,"avatar_url":"https://avatars.githubusercontent.com/u/16591014?v=3","gravatar_id":"","url":"https://api.github.com/users/vramperez","html_url":"https://github.com/vramperez","followers_url":"https://api.github.com/users/vramperez/followers","following_url":"https://api.github.com/users/vramperez/following{/other_user}","gists_url":"https://api.github.com/users/vramperez/gists{/gist_id}","starred_url":"https://api.github.com/users/vramperez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vramperez/subscriptions","organizations_url":"https://api.github.com/users/vramperez/orgs","repos_url":"https://api.github.com/users/vramperez/repos","events_url":"https://api.github.com/users/vramperez/events{/privacy}","received_events_url":"https://api.github.com/users/vramperez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vramperez/business-ecosystem-logic-proxy","description":"Business Logic Layer for the TMForum Frameworkx APIs + Portal to access them in an easy way","fork":true,"url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy","forks_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/forks","keys_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/teams","hooks_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/hooks","issue_events_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/issues/events{/number}","events_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/events","assignees_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/assignees{/user}","branches_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/branches{/branch}","tags_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/tags","blobs_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/statuses/{sha}","languages_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/languages","stargazers_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/stargazers","contributors_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/contributors","subscribers_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/subscribers","subscription_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/subscription","commits_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/contents/{+path}","compare_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/merges","archive_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/downloads","issues_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/issues{/number}","pulls_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/pulls{/number}","milestones_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/milestones{/number}","notifications_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/labels{/name}","releases_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/releases{/id}","deployments_url":"https://api.github.com/repos/vramperez/business-ecosystem-logic-proxy/deployments","created_at":"2016-04-18T11:01:45Z","updated_at":"2016-04-18T11:01:46Z","pushed_at":"2016-04-27T10:50:18Z","git_url":"git://github.com/vramperez/business-ecosystem-logic-proxy.git","ssh_url":"git@github.com:vramperez/business-ecosystem-logic-proxy.git","clone_url":"https://github.com/vramperez/business-ecosystem-logic-proxy.git","svn_url":"https://github.com/vramperez/business-ecosystem-logic-proxy","homepage":"","size":3005,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"FIWARE-TMForum:feature/usage-integration","ref":"feature/usage-integration","sha":"e4eae28b7470029505e769f439e25b21c5c2d825","user":{"login":"FIWARE-TMForum","id":15013013,"avatar_url":"https://avatars.githubusercontent.com/u/15013013?v=3","gravatar_id":"","url":"https://api.github.com/users/FIWARE-TMForum","html_url":"https://github.com/FIWARE-TMForum","followers_url":"https://api.github.com/users/FIWARE-TMForum/followers","following_url":"https://api.github.com/users/FIWARE-TMForum/following{/other_user}","gists_url":"https://api.github.com/users/FIWARE-TMForum/gists{/gist_id}","starred_url":"https://api.github.com/users/FIWARE-TMForum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FIWARE-TMForum/subscriptions","organizations_url":"https://api.github.com/users/FIWARE-TMForum/orgs","repos_url":"https://api.github.com/users/FIWARE-TMForum/repos","events_url":"https://api.github.com/users/FIWARE-TMForum/events{/privacy}","received_events_url":"https://api.github.com/users/FIWARE-TMForum/received_events","type":"Organization","site_admin":false},"repo":{"id":43949977,"name":"business-ecosystem-logic-proxy","full_name":"FIWARE-TMForum/business-ecosystem-logic-proxy","owner":{"login":"FIWARE-TMForum","id":15013013,"avatar_url":"https://avatars.githubusercontent.com/u/15013013?v=3","gravatar_id":"","url":"https://api.github.com/users/FIWARE-TMForum","html_url":"https://github.com/FIWARE-TMForum","followers_url":"https://api.github.com/users/FIWARE-TMForum/followers","following_url":"https://api.github.com/users/FIWARE-TMForum/following{/other_user}","gists_url":"https://api.github.com/users/FIWARE-TMForum/gists{/gist_id}","starred_url":"https://api.github.com/users/FIWARE-TMForum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FIWARE-TMForum/subscriptions","organizations_url":"https://api.github.com/users/FIWARE-TMForum/orgs","repos_url":"https://api.github.com/users/FIWARE-TMForum/repos","events_url":"https://api.github.com/users/FIWARE-TMForum/events{/privacy}","received_events_url":"https://api.github.com/users/FIWARE-TMForum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FIWARE-TMForum/business-ecosystem-logic-proxy","description":"Business Logic Layer for the TMForum Frameworkx APIs + Portal to access them in an easy way","fork":false,"url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy","forks_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/forks","keys_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/teams","hooks_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/hooks","issue_events_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/issues/events{/number}","events_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/events","assignees_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/assignees{/user}","branches_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/branches{/branch}","tags_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/tags","blobs_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/statuses/{sha}","languages_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/languages","stargazers_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/stargazers","contributors_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/contributors","subscribers_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/subscribers","subscription_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/subscription","commits_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/contents/{+path}","compare_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/merges","archive_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/downloads","issues_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/issues{/number}","pulls_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls{/number}","milestones_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/milestones{/number}","notifications_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/labels{/name}","releases_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/releases{/id}","deployments_url":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/deployments","created_at":"2015-10-09T10:53:07Z","updated_at":"2016-01-25T11:13:15Z","pushed_at":"2016-04-28T12:57:27Z","git_url":"git://github.com/FIWARE-TMForum/business-ecosystem-logic-proxy.git","ssh_url":"git@github.com:FIWARE-TMForum/business-ecosystem-logic-proxy.git","clone_url":"https://github.com/FIWARE-TMForum/business-ecosystem-logic-proxy.git","svn_url":"https://github.com/FIWARE-TMForum/business-ecosystem-logic-proxy","homepage":"","size":3089,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":10,"forks":2,"open_issues":10,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/66"},"html":{"href":"https://github.com/FIWARE-TMForum/business-ecosystem-logic-proxy/pull/66"},"issue":{"href":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/issues/66"},"comments":{"href":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/FIWARE-TMForum/business-ecosystem-logic-proxy/statuses/d4aec35bc5f540abe359f917b05847110c42f5aa"}}}}