{"action":"created","comment":{"url":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/comments/33401669","id":33401669,"diff_hunk":"@@ -0,0 +1,120 @@\n+require \"uri\"\n+require \"net/http\"\n+require \"cgi\"\n+require 'lita'\n+\n+module Lita\n+  module Handlers\n+    class Youtrack < Handler\n+      def initialize(robot)\n+        super\n+      end\n+\n+      def self.default_config(config)\n+        config.login = nil\n+        config.password = nil\n+      end\n+      route(/\\bproject (\\w+)?/i, :project, command: true, help: { \"project car\" => \"Displays the issues with youtrack project car\"})\n+      route(/\\bprojects\\b/i, :projects, command: true, help: { \"projects\" => \"Displays a list of projects and their short names\"})\n+      route(/\\bbugs\\b/i, :bugs, command: true, help: { \"bugs\" => \"Display all issues with filter -Done -{Parking Lot} #Bug sort by: AMA_Priorities, Updated \"})\n+\n+\n+      def project(response)\n+        project_name = response.matches[0][0]\n+        uri = URI(\"https://ama-digital.myjetbrains.com/youtrack/rest/export/#{project_name}/issues\")\n+        response_body = callHTTP(uri)\n+        parse_data = parseProject(response_body)\n+        response.reply projectResponse(parse_data,project_name)\n+      end\n+\n+      def projects(response)\n+        uri = URI(\"https://ama-digital.myjetbrains.com/youtrack/rest/project/all\")\n+        response_body = callHTTP(uri)\n+        parse_data = parseProjects(response_body)\n+        response.reply projectsResponse(parse_data)\n+      end\n+\n+      def bugs(response)\n+        uri = URI(\"https://ama-digital.myjetbrains.com/youtrack/rest/issue?filter=%23Bug+-Done+-%7BParking+Lot%7D+sort+by%3A+AMA_Priorities%2C+Updated\")\n+        response_body = callHTTP(uri)\n+        parse_data = parseBugs(response_body)\n+        response.reply bugsResponse(parse_data)\n+      end\n+\n+      def body(resp)\n+        resp.body\n+      end\n+\n+      def login\n+        name = youlogin\n+        password = youpassword\n+        x = Net::HTTP.post_form(URI.parse('https://ama-digital.myjetbrains.com/youtrack/rest/user/login'), 'login' => name, 'password' => password)\n+        cookie = x['set-cookie']\n+        headers = { 'Cookie' => cookie }\n+      end\n+\n+      private\n+\n+      def parseProject(response_body)\n+        data_hash = { :responseString => \"\" , :numbers => [] , :longnames => response_body.scan(/<field name=\"summary\"> *<value>(.*?)<\\/value>/i) }\n+        response_body.scan(/name=\"numberInProject\"><value>\\d*/i) { |m| data_hash[:numbers] << m.scan(/[0-9]+/).first }\n+        data_hash[:responseString] = \"Project not found - type 'lita projects' for list\" if data_hash[:longnames].count==0","path":"lib/lita/handlers/youtrack.rb","position":61,"original_position":61,"commit_id":"8c35aca3df0aff49594acb988356d27bb3088798","original_commit_id":"8c35aca3df0aff49594acb988356d27bb3088798","user":{"login":"MathieuGilbert","id":473578,"avatar_url":"https://avatars.githubusercontent.com/u/473578?v=3","gravatar_id":"","url":"https://api.github.com/users/MathieuGilbert","html_url":"https://github.com/MathieuGilbert","followers_url":"https://api.github.com/users/MathieuGilbert/followers","following_url":"https://api.github.com/users/MathieuGilbert/following{/other_user}","gists_url":"https://api.github.com/users/MathieuGilbert/gists{/gist_id}","starred_url":"https://api.github.com/users/MathieuGilbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MathieuGilbert/subscriptions","organizations_url":"https://api.github.com/users/MathieuGilbert/orgs","repos_url":"https://api.github.com/users/MathieuGilbert/repos","events_url":"https://api.github.com/users/MathieuGilbert/events{/privacy}","received_events_url":"https://api.github.com/users/MathieuGilbert/received_events","type":"User","site_admin":false},"body":"Spaces around `==`.","created_at":"2015-06-26T22:28:32Z","updated_at":"2015-06-26T22:28:32Z","html_url":"https://github.com/amaabca/lita-youtrack/pull/1#discussion_r33401669","pull_request_url":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/comments/33401669"},"html":{"href":"https://github.com/amaabca/lita-youtrack/pull/1#discussion_r33401669"},"pull_request":{"href":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/1","id":38019806,"html_url":"https://github.com/amaabca/lita-youtrack/pull/1","diff_url":"https://github.com/amaabca/lita-youtrack/pull/1.diff","patch_url":"https://github.com/amaabca/lita-youtrack/pull/1.patch","issue_url":"https://api.github.com/repos/amaabca/lita-youtrack/issues/1","number":1,"state":"open","locked":false,"title":"Wrote tests, split functionality into multiple functions, removed spare files, includes, comments","user":{"login":"weyermannx","id":11400938,"avatar_url":"https://avatars.githubusercontent.com/u/11400938?v=3","gravatar_id":"","url":"https://api.github.com/users/weyermannx","html_url":"https://github.com/weyermannx","followers_url":"https://api.github.com/users/weyermannx/followers","following_url":"https://api.github.com/users/weyermannx/following{/other_user}","gists_url":"https://api.github.com/users/weyermannx/gists{/gist_id}","starred_url":"https://api.github.com/users/weyermannx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weyermannx/subscriptions","organizations_url":"https://api.github.com/users/weyermannx/orgs","repos_url":"https://api.github.com/users/weyermannx/repos","events_url":"https://api.github.com/users/weyermannx/events{/privacy}","received_events_url":"https://api.github.com/users/weyermannx/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-18T15:31:54Z","updated_at":"2015-06-26T22:28:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d9809b78ebcdb4dcb8334e73bfe9cb3bd43ec233","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/1/commits","review_comments_url":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/1/comments","review_comment_url":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amaabca/lita-youtrack/issues/1/comments","statuses_url":"https://api.github.com/repos/amaabca/lita-youtrack/statuses/8c35aca3df0aff49594acb988356d27bb3088798","head":{"label":"amaabca:lita-youtrack","ref":"lita-youtrack","sha":"8c35aca3df0aff49594acb988356d27bb3088798","user":{"login":"amaabca","id":1038934,"avatar_url":"https://avatars.githubusercontent.com/u/1038934?v=3","gravatar_id":"","url":"https://api.github.com/users/amaabca","html_url":"https://github.com/amaabca","followers_url":"https://api.github.com/users/amaabca/followers","following_url":"https://api.github.com/users/amaabca/following{/other_user}","gists_url":"https://api.github.com/users/amaabca/gists{/gist_id}","starred_url":"https://api.github.com/users/amaabca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amaabca/subscriptions","organizations_url":"https://api.github.com/users/amaabca/orgs","repos_url":"https://api.github.com/users/amaabca/repos","events_url":"https://api.github.com/users/amaabca/events{/privacy}","received_events_url":"https://api.github.com/users/amaabca/received_events","type":"Organization","site_admin":false},"repo":{"id":37334253,"name":"lita-youtrack","full_name":"amaabca/lita-youtrack","owner":{"login":"amaabca","id":1038934,"avatar_url":"https://avatars.githubusercontent.com/u/1038934?v=3","gravatar_id":"","url":"https://api.github.com/users/amaabca","html_url":"https://github.com/amaabca","followers_url":"https://api.github.com/users/amaabca/followers","following_url":"https://api.github.com/users/amaabca/following{/other_user}","gists_url":"https://api.github.com/users/amaabca/gists{/gist_id}","starred_url":"https://api.github.com/users/amaabca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amaabca/subscriptions","organizations_url":"https://api.github.com/users/amaabca/orgs","repos_url":"https://api.github.com/users/amaabca/repos","events_url":"https://api.github.com/users/amaabca/events{/privacy}","received_events_url":"https://api.github.com/users/amaabca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/amaabca/lita-youtrack","description":"youtrack integration for lita","fork":false,"url":"https://api.github.com/repos/amaabca/lita-youtrack","forks_url":"https://api.github.com/repos/amaabca/lita-youtrack/forks","keys_url":"https://api.github.com/repos/amaabca/lita-youtrack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amaabca/lita-youtrack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amaabca/lita-youtrack/teams","hooks_url":"https://api.github.com/repos/amaabca/lita-youtrack/hooks","issue_events_url":"https://api.github.com/repos/amaabca/lita-youtrack/issues/events{/number}","events_url":"https://api.github.com/repos/amaabca/lita-youtrack/events","assignees_url":"https://api.github.com/repos/amaabca/lita-youtrack/assignees{/user}","branches_url":"https://api.github.com/repos/amaabca/lita-youtrack/branches{/branch}","tags_url":"https://api.github.com/repos/amaabca/lita-youtrack/tags","blobs_url":"https://api.github.com/repos/amaabca/lita-youtrack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amaabca/lita-youtrack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amaabca/lita-youtrack/git/refs{/sha}","trees_url":"https://api.github.com/repos/amaabca/lita-youtrack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amaabca/lita-youtrack/statuses/{sha}","languages_url":"https://api.github.com/repos/amaabca/lita-youtrack/languages","stargazers_url":"https://api.github.com/repos/amaabca/lita-youtrack/stargazers","contributors_url":"https://api.github.com/repos/amaabca/lita-youtrack/contributors","subscribers_url":"https://api.github.com/repos/amaabca/lita-youtrack/subscribers","subscription_url":"https://api.github.com/repos/amaabca/lita-youtrack/subscription","commits_url":"https://api.github.com/repos/amaabca/lita-youtrack/commits{/sha}","git_commits_url":"https://api.github.com/repos/amaabca/lita-youtrack/git/commits{/sha}","comments_url":"https://api.github.com/repos/amaabca/lita-youtrack/comments{/number}","issue_comment_url":"https://api.github.com/repos/amaabca/lita-youtrack/issues/comments{/number}","contents_url":"https://api.github.com/repos/amaabca/lita-youtrack/contents/{+path}","compare_url":"https://api.github.com/repos/amaabca/lita-youtrack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amaabca/lita-youtrack/merges","archive_url":"https://api.github.com/repos/amaabca/lita-youtrack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amaabca/lita-youtrack/downloads","issues_url":"https://api.github.com/repos/amaabca/lita-youtrack/issues{/number}","pulls_url":"https://api.github.com/repos/amaabca/lita-youtrack/pulls{/number}","milestones_url":"https://api.github.com/repos/amaabca/lita-youtrack/milestones{/number}","notifications_url":"https://api.github.com/repos/amaabca/lita-youtrack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amaabca/lita-youtrack/labels{/name}","releases_url":"https://api.github.com/repos/amaabca/lita-youtrack/releases{/id}","created_at":"2015-06-12T17:07:09Z","updated_at":"2015-06-16T21:36:13Z","pushed_at":"2015-06-26T15:52:16Z","git_url":"git://github.com/amaabca/lita-youtrack.git","ssh_url":"git@github.com:amaabca/lita-youtrack.git","clone_url":"https://github.com/amaabca/lita-youtrack.git","svn_url":"https://github.com/amaabca/lita-youtrack","homepage":null,"size":245,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"amaabca:master","ref":"master","sha":"c2036de99c3049bccf39ae679c232f0358296daa","user":{"login":"amaabca","id":1038934,"avatar_url":"https://avatars.githubusercontent.com/u/1038934?v=3","gravatar_id":"","url":"https://api.github.com/users/amaabca","html_url":"https://github.com/amaabca","followers_url":"https://api.github.com/users/amaabca/followers","following_url":"https://api.github.com/users/amaabca/following{/other_user}","gists_url":"https://api.github.com/users/amaabca/gists{/gist_id}","starred_url":"https://api.github.com/users/amaabca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amaabca/subscriptions","organizations_url":"https://api.github.com/users/amaabca/orgs","repos_url":"https://api.github.com/users/amaabca/repos","events_url":"https://api.github.com/users/amaabca/events{/privacy}","received_events_url":"https://api.github.com/users/amaabca/received_events","type":"Organization","site_admin":false},"repo":{"id":37334253,"name":"lita-youtrack","full_name":"amaabca/lita-youtrack","owner":{"login":"amaabca","id":1038934,"avatar_url":"https://avatars.githubusercontent.com/u/1038934?v=3","gravatar_id":"","url":"https://api.github.com/users/amaabca","html_url":"https://github.com/amaabca","followers_url":"https://api.github.com/users/amaabca/followers","following_url":"https://api.github.com/users/amaabca/following{/other_user}","gists_url":"https://api.github.com/users/amaabca/gists{/gist_id}","starred_url":"https://api.github.com/users/amaabca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amaabca/subscriptions","organizations_url":"https://api.github.com/users/amaabca/orgs","repos_url":"https://api.github.com/users/amaabca/repos","events_url":"https://api.github.com/users/amaabca/events{/privacy}","received_events_url":"https://api.github.com/users/amaabca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/amaabca/lita-youtrack","description":"youtrack integration for lita","fork":false,"url":"https://api.github.com/repos/amaabca/lita-youtrack","forks_url":"https://api.github.com/repos/amaabca/lita-youtrack/forks","keys_url":"https://api.github.com/repos/amaabca/lita-youtrack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amaabca/lita-youtrack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amaabca/lita-youtrack/teams","hooks_url":"https://api.github.com/repos/amaabca/lita-youtrack/hooks","issue_events_url":"https://api.github.com/repos/amaabca/lita-youtrack/issues/events{/number}","events_url":"https://api.github.com/repos/amaabca/lita-youtrack/events","assignees_url":"https://api.github.com/repos/amaabca/lita-youtrack/assignees{/user}","branches_url":"https://api.github.com/repos/amaabca/lita-youtrack/branches{/branch}","tags_url":"https://api.github.com/repos/amaabca/lita-youtrack/tags","blobs_url":"https://api.github.com/repos/amaabca/lita-youtrack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amaabca/lita-youtrack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amaabca/lita-youtrack/git/refs{/sha}","trees_url":"https://api.github.com/repos/amaabca/lita-youtrack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amaabca/lita-youtrack/statuses/{sha}","languages_url":"https://api.github.com/repos/amaabca/lita-youtrack/languages","stargazers_url":"https://api.github.com/repos/amaabca/lita-youtrack/stargazers","contributors_url":"https://api.github.com/repos/amaabca/lita-youtrack/contributors","subscribers_url":"https://api.github.com/repos/amaabca/lita-youtrack/subscribers","subscription_url":"https://api.github.com/repos/amaabca/lita-youtrack/subscription","commits_url":"https://api.github.com/repos/amaabca/lita-youtrack/commits{/sha}","git_commits_url":"https://api.github.com/repos/amaabca/lita-youtrack/git/commits{/sha}","comments_url":"https://api.github.com/repos/amaabca/lita-youtrack/comments{/number}","issue_comment_url":"https://api.github.com/repos/amaabca/lita-youtrack/issues/comments{/number}","contents_url":"https://api.github.com/repos/amaabca/lita-youtrack/contents/{+path}","compare_url":"https://api.github.com/repos/amaabca/lita-youtrack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amaabca/lita-youtrack/merges","archive_url":"https://api.github.com/repos/amaabca/lita-youtrack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amaabca/lita-youtrack/downloads","issues_url":"https://api.github.com/repos/amaabca/lita-youtrack/issues{/number}","pulls_url":"https://api.github.com/repos/amaabca/lita-youtrack/pulls{/number}","milestones_url":"https://api.github.com/repos/amaabca/lita-youtrack/milestones{/number}","notifications_url":"https://api.github.com/repos/amaabca/lita-youtrack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amaabca/lita-youtrack/labels{/name}","releases_url":"https://api.github.com/repos/amaabca/lita-youtrack/releases{/id}","created_at":"2015-06-12T17:07:09Z","updated_at":"2015-06-16T21:36:13Z","pushed_at":"2015-06-26T15:52:16Z","git_url":"git://github.com/amaabca/lita-youtrack.git","ssh_url":"git@github.com:amaabca/lita-youtrack.git","clone_url":"https://github.com/amaabca/lita-youtrack.git","svn_url":"https://github.com/amaabca/lita-youtrack","homepage":null,"size":245,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/1"},"html":{"href":"https://github.com/amaabca/lita-youtrack/pull/1"},"issue":{"href":"https://api.github.com/repos/amaabca/lita-youtrack/issues/1"},"comments":{"href":"https://api.github.com/repos/amaabca/lita-youtrack/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amaabca/lita-youtrack/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/amaabca/lita-youtrack/statuses/8c35aca3df0aff49594acb988356d27bb3088798"}}}}