{"action":"created","comment":{"url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/comments/184792340","pull_request_review_id":116065719,"id":184792340,"diff_hunk":"@@ -0,0 +1,63 @@\n+\"\"\"\n+Api for teams\n+\"\"\"\n+import os\n+import logging\n+import requests\n+from oauthlib.oauth2 import LegacyApplicationClient\n+from requests_oauthlib import OAuth2Session\n+\n+LOG = logging.getLogger(__name__)\n+os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'\n+\n+\n+class ApiTeams(object):  #pylint: disable=too-few-public-methods\n+\n+    headers = {}\n+    API_PATH = 'api/team/v0'\n+\n+    def __init__(self, username, password, client_id, client_secret,  # pylint: disable=too-many-arguments\n+                 server_url='http://127.0.0.1:8000'):\n+        \"\"\"Creates a ApiTeams object\"\"\"\n+        self.server_url = server_url\n+        self.client_id = client_id\n+        self.client_secret = client_secret\n+        self.password = password\n+        self.username = username\n+        self.headers[\"Authorization\"] = \"{} {}\".format(\n+            \"Bearer\", self._get_token(server_url))\n+\n+    def _get_token(self, server_url):\n+        \"\"\"This method get the Authorization token\"\"\"\n+        client_id = self.client_id\n+        client_secret = self.client_secret\n+\n+        oauth = OAuth2Session(\n+            client=LegacyApplicationClient(client_id=client_id))\n+        token_url = \"/\".join([server_url, \"oauth2/access_token/\"])\n+\n+        token = oauth.fetch_token(token_url=token_url,\n+                                  client_id=client_id,\n+                                  client_secret=client_secret,\n+                                  username=self.username,\n+                                  password=self.password)\n+\n+        LOG.info(\"The acces token is: %s\", token[\"access_token\"])\n+\n+        return token['access_token']\n+\n+    def _call_api_get(self, url_path):\n+        \"\"\"This method return the response\"\"\"\n+        url = \"/\".join([self.server_url, self.API_PATH, url_path])\n+        return requests.get(url, headers=self.headers)\n+\n+    def get_user_team(self, course_id, username):","path":"rocketc/api_teams.py","position":54,"original_position":54,"commit_id":"851b551aac54f0311beee37398fdd4b2f31fb77b","original_commit_id":"851b551aac54f0311beee37398fdd4b2f31fb77b","user":{"login":"andrey-canon","id":36200299,"avatar_url":"https://avatars2.githubusercontent.com/u/36200299?v=4","gravatar_id":"","url":"https://api.github.com/users/andrey-canon","html_url":"https://github.com/andrey-canon","followers_url":"https://api.github.com/users/andrey-canon/followers","following_url":"https://api.github.com/users/andrey-canon/following{/other_user}","gists_url":"https://api.github.com/users/andrey-canon/gists{/gist_id}","starred_url":"https://api.github.com/users/andrey-canon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrey-canon/subscriptions","organizations_url":"https://api.github.com/users/andrey-canon/orgs","repos_url":"https://api.github.com/users/andrey-canon/repos","events_url":"https://api.github.com/users/andrey-canon/events{/privacy}","received_events_url":"https://api.github.com/users/andrey-canon/received_events","type":"User","site_admin":false},"body":"there is a way to get that but have to import dependencies from edx ","created_at":"2018-04-27T20:00:00Z","updated_at":"2018-04-27T20:00:00Z","html_url":"https://github.com/eduNEXT/rocket-chat-extension/pull/21#discussion_r184792340","pull_request_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/21","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/comments/184792340"},"html":{"href":"https://github.com/eduNEXT/rocket-chat-extension/pull/21#discussion_r184792340"},"pull_request":{"href":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/21"}},"in_reply_to_id":184782392},"pull_request":{"url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/21","id":183560061,"html_url":"https://github.com/eduNEXT/rocket-chat-extension/pull/21","diff_url":"https://github.com/eduNEXT/rocket-chat-extension/pull/21.diff","patch_url":"https://github.com/eduNEXT/rocket-chat-extension/pull/21.patch","issue_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/issues/21","number":21,"state":"open","locked":false,"title":"And/team aware","user":{"login":"andrey-canon","id":36200299,"avatar_url":"https://avatars2.githubusercontent.com/u/36200299?v=4","gravatar_id":"","url":"https://api.github.com/users/andrey-canon","html_url":"https://github.com/andrey-canon","followers_url":"https://api.github.com/users/andrey-canon/followers","following_url":"https://api.github.com/users/andrey-canon/following{/other_user}","gists_url":"https://api.github.com/users/andrey-canon/gists{/gist_id}","starred_url":"https://api.github.com/users/andrey-canon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrey-canon/subscriptions","organizations_url":"https://api.github.com/users/andrey-canon/orgs","repos_url":"https://api.github.com/users/andrey-canon/repos","events_url":"https://api.github.com/users/andrey-canon/events{/privacy}","received_events_url":"https://api.github.com/users/andrey-canon/received_events","type":"User","site_admin":false},"body":"## Description\r\nThis branch allows to get the user's team and add the user to it, include the option in studio to embed the channel.\r\n\r\n## Reviewers \r\n\r\n- [ ] @felipemontoya \r\n- [ ] @jfavellar90 ","created_at":"2018-04-23T21:16:27Z","updated_at":"2018-04-27T20:00:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06c3db38d05591b63ff7814f4e9f8f7fd9cedeb7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/21/commits","review_comments_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/21/comments","review_comment_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/issues/21/comments","statuses_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/statuses/851b551aac54f0311beee37398fdd4b2f31fb77b","head":{"label":"eduNEXT:and/team_aware","ref":"and/team_aware","sha":"851b551aac54f0311beee37398fdd4b2f31fb77b","user":{"login":"eduNEXT","id":5911140,"avatar_url":"https://avatars0.githubusercontent.com/u/5911140?v=4","gravatar_id":"","url":"https://api.github.com/users/eduNEXT","html_url":"https://github.com/eduNEXT","followers_url":"https://api.github.com/users/eduNEXT/followers","following_url":"https://api.github.com/users/eduNEXT/following{/other_user}","gists_url":"https://api.github.com/users/eduNEXT/gists{/gist_id}","starred_url":"https://api.github.com/users/eduNEXT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduNEXT/subscriptions","organizations_url":"https://api.github.com/users/eduNEXT/orgs","repos_url":"https://api.github.com/users/eduNEXT/repos","events_url":"https://api.github.com/users/eduNEXT/events{/privacy}","received_events_url":"https://api.github.com/users/eduNEXT/received_events","type":"Organization","site_admin":false},"repo":{"id":126202791,"name":"rocket-chat-extension","full_name":"eduNEXT/rocket-chat-extension","owner":{"login":"eduNEXT","id":5911140,"avatar_url":"https://avatars0.githubusercontent.com/u/5911140?v=4","gravatar_id":"","url":"https://api.github.com/users/eduNEXT","html_url":"https://github.com/eduNEXT","followers_url":"https://api.github.com/users/eduNEXT/followers","following_url":"https://api.github.com/users/eduNEXT/following{/other_user}","gists_url":"https://api.github.com/users/eduNEXT/gists{/gist_id}","starred_url":"https://api.github.com/users/eduNEXT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduNEXT/subscriptions","organizations_url":"https://api.github.com/users/eduNEXT/orgs","repos_url":"https://api.github.com/users/eduNEXT/repos","events_url":"https://api.github.com/users/eduNEXT/events{/privacy}","received_events_url":"https://api.github.com/users/eduNEXT/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eduNEXT/rocket-chat-extension","description":null,"fork":false,"url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension","forks_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/forks","keys_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/teams","hooks_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/hooks","issue_events_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/issues/events{/number}","events_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/events","assignees_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/assignees{/user}","branches_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/branches{/branch}","tags_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/tags","blobs_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/git/refs{/sha}","trees_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/statuses/{sha}","languages_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/languages","stargazers_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/stargazers","contributors_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/contributors","subscribers_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/subscribers","subscription_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/subscription","commits_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/commits{/sha}","git_commits_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/git/commits{/sha}","comments_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/comments{/number}","issue_comment_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/issues/comments{/number}","contents_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/contents/{+path}","compare_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/merges","archive_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/downloads","issues_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/issues{/number}","pulls_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls{/number}","milestones_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/milestones{/number}","notifications_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/labels{/name}","releases_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/releases{/id}","deployments_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/deployments","created_at":"2018-03-21T15:46:26Z","updated_at":"2018-04-27T15:42:17Z","pushed_at":"2018-04-27T15:45:01Z","git_url":"git://github.com/eduNEXT/rocket-chat-extension.git","ssh_url":"git@github.com:eduNEXT/rocket-chat-extension.git","clone_url":"https://github.com/eduNEXT/rocket-chat-extension.git","svn_url":"https://github.com/eduNEXT/rocket-chat-extension","homepage":null,"size":40241,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"eduNEXT:master","ref":"master","sha":"bd76cddb467f44e64034b5392568e12a361b4db4","user":{"login":"eduNEXT","id":5911140,"avatar_url":"https://avatars0.githubusercontent.com/u/5911140?v=4","gravatar_id":"","url":"https://api.github.com/users/eduNEXT","html_url":"https://github.com/eduNEXT","followers_url":"https://api.github.com/users/eduNEXT/followers","following_url":"https://api.github.com/users/eduNEXT/following{/other_user}","gists_url":"https://api.github.com/users/eduNEXT/gists{/gist_id}","starred_url":"https://api.github.com/users/eduNEXT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduNEXT/subscriptions","organizations_url":"https://api.github.com/users/eduNEXT/orgs","repos_url":"https://api.github.com/users/eduNEXT/repos","events_url":"https://api.github.com/users/eduNEXT/events{/privacy}","received_events_url":"https://api.github.com/users/eduNEXT/received_events","type":"Organization","site_admin":false},"repo":{"id":126202791,"name":"rocket-chat-extension","full_name":"eduNEXT/rocket-chat-extension","owner":{"login":"eduNEXT","id":5911140,"avatar_url":"https://avatars0.githubusercontent.com/u/5911140?v=4","gravatar_id":"","url":"https://api.github.com/users/eduNEXT","html_url":"https://github.com/eduNEXT","followers_url":"https://api.github.com/users/eduNEXT/followers","following_url":"https://api.github.com/users/eduNEXT/following{/other_user}","gists_url":"https://api.github.com/users/eduNEXT/gists{/gist_id}","starred_url":"https://api.github.com/users/eduNEXT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduNEXT/subscriptions","organizations_url":"https://api.github.com/users/eduNEXT/orgs","repos_url":"https://api.github.com/users/eduNEXT/repos","events_url":"https://api.github.com/users/eduNEXT/events{/privacy}","received_events_url":"https://api.github.com/users/eduNEXT/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eduNEXT/rocket-chat-extension","description":null,"fork":false,"url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension","forks_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/forks","keys_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/teams","hooks_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/hooks","issue_events_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/issues/events{/number}","events_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/events","assignees_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/assignees{/user}","branches_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/branches{/branch}","tags_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/tags","blobs_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/git/refs{/sha}","trees_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/statuses/{sha}","languages_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/languages","stargazers_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/stargazers","contributors_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/contributors","subscribers_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/subscribers","subscription_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/subscription","commits_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/commits{/sha}","git_commits_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/git/commits{/sha}","comments_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/comments{/number}","issue_comment_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/issues/comments{/number}","contents_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/contents/{+path}","compare_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/merges","archive_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/downloads","issues_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/issues{/number}","pulls_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls{/number}","milestones_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/milestones{/number}","notifications_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/labels{/name}","releases_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/releases{/id}","deployments_url":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/deployments","created_at":"2018-03-21T15:46:26Z","updated_at":"2018-04-27T15:42:17Z","pushed_at":"2018-04-27T15:45:01Z","git_url":"git://github.com/eduNEXT/rocket-chat-extension.git","ssh_url":"git@github.com:eduNEXT/rocket-chat-extension.git","clone_url":"https://github.com/eduNEXT/rocket-chat-extension.git","svn_url":"https://github.com/eduNEXT/rocket-chat-extension","homepage":null,"size":40241,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/21"},"html":{"href":"https://github.com/eduNEXT/rocket-chat-extension/pull/21"},"issue":{"href":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/issues/21"},"comments":{"href":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/eduNEXT/rocket-chat-extension/statuses/851b551aac54f0311beee37398fdd4b2f31fb77b"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"andrey-canon"}}