{"action":"created","comment":{"url":"https://api.github.com/repos/centraldesktop/api-php/pulls/comments/35175085","id":35175085,"diff_hunk":"@@ -0,0 +1,112 @@\n+<?php\n+/**\n+ * Created by IntelliJ IDEA.\n+ * User: thyde\n+ * Date: 7/21/15\n+ * Time: 6:06 PM\n+ */\n+\n+namespace CentralDesktop\\API;\n+\n+use GuzzleHttp\\Client;\n+use GuzzleHttp\\HandlerStack;\n+use GuzzleHttp\\Middleware;\n+use JWT;\n+\n+use Psr\\Http\\Message\\RequestInterface;\n+use Symfony\\Component\\Config\\FileLocator;\n+use Symfony\\Component\\DependencyInjection\\Container;\n+use Symfony\\Component\\DependencyInjection\\ContainerBuilder;\n+use Symfony\\Component\\DependencyInjection\\Loader\\YamlFileLoader;\n+\n+class ClientFactory {\n+    public static  $debug = false;\n+    private static $token = null;\n+    /** @var Container Configuration Container */\n+    private static $container = null;\n+\n+    private static\n+    function setup() {\n+        if (!is_null(self::$container)) {\n+            return self::$container;\n+        }\n+\n+        $container = new ContainerBuilder();\n+        $loader    = new YamlFileLoader($container, new FileLocator(__DIR__ . \"/../config\"));\n+\n+        $loader->load('client_config.yml');\n+        $loader->load('config.yml');\n+\n+\n+        if (empty($container->getParameter('client.id')) || empty($container->getParameter('client.key'))) {\n+            throw new Exception(\"Please configure client.id and client.key in client_config.yml\");\n+        }\n+\n+        self::$container = $container;\n+\n+        return $container;\n+    }\n+\n+    public static\n+    function getClient() {\n+        $container = self::setup();\n+\n+        $stack = new HandlerStack();\n+        $stack->setHandler(\\GuzzleHttp\\choose_handler());\n+\n+        $token = self::getAuthToken();\n+\n+        $stack->push(Middleware::mapRequest(function (RequestInterface $r) use ($token) {","path":"src/ClientFactory.php","position":59,"original_position":59,"commit_id":"58aff4e9bbc1a30e3986261843fcae4333ed2fed","original_commit_id":"58aff4e9bbc1a30e3986261843fcae4333ed2fed","user":{"login":"treyhyde","id":62077,"avatar_url":"https://avatars.githubusercontent.com/u/62077?v=3","gravatar_id":"","url":"https://api.github.com/users/treyhyde","html_url":"https://github.com/treyhyde","followers_url":"https://api.github.com/users/treyhyde/followers","following_url":"https://api.github.com/users/treyhyde/following{/other_user}","gists_url":"https://api.github.com/users/treyhyde/gists{/gist_id}","starred_url":"https://api.github.com/users/treyhyde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treyhyde/subscriptions","organizations_url":"https://api.github.com/users/treyhyde/orgs","repos_url":"https://api.github.com/users/treyhyde/repos","events_url":"https://api.github.com/users/treyhyde/events{/privacy}","received_events_url":"https://api.github.com/users/treyhyde/received_events","type":"User","site_admin":false},"body":"this is fun","created_at":"2015-07-22T02:04:41Z","updated_at":"2015-07-22T02:04:41Z","html_url":"https://github.com/centraldesktop/api-php/pull/1#discussion_r35175085","pull_request_url":"https://api.github.com/repos/centraldesktop/api-php/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/centraldesktop/api-php/pulls/comments/35175085"},"html":{"href":"https://github.com/centraldesktop/api-php/pull/1#discussion_r35175085"},"pull_request":{"href":"https://api.github.com/repos/centraldesktop/api-php/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/centraldesktop/api-php/pulls/1","id":40523599,"html_url":"https://github.com/centraldesktop/api-php/pull/1","diff_url":"https://github.com/centraldesktop/api-php/pull/1.diff","patch_url":"https://github.com/centraldesktop/api-php/pull/1.patch","issue_url":"https://api.github.com/repos/centraldesktop/api-php/issues/1","number":1,"state":"open","locked":false,"title":"Sample code for PHP.","user":{"login":"treyhyde","id":62077,"avatar_url":"https://avatars.githubusercontent.com/u/62077?v=3","gravatar_id":"","url":"https://api.github.com/users/treyhyde","html_url":"https://github.com/treyhyde","followers_url":"https://api.github.com/users/treyhyde/followers","following_url":"https://api.github.com/users/treyhyde/following{/other_user}","gists_url":"https://api.github.com/users/treyhyde/gists{/gist_id}","starred_url":"https://api.github.com/users/treyhyde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treyhyde/subscriptions","organizations_url":"https://api.github.com/users/treyhyde/orgs","repos_url":"https://api.github.com/users/treyhyde/repos","events_url":"https://api.github.com/users/treyhyde/events{/privacy}","received_events_url":"https://api.github.com/users/treyhyde/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-22T01:58:05Z","updated_at":"2015-07-22T02:04:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"350133c89edd735dc34cd4a1052cdf092e72e160","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/centraldesktop/api-php/pulls/1/commits","review_comments_url":"https://api.github.com/repos/centraldesktop/api-php/pulls/1/comments","review_comment_url":"https://api.github.com/repos/centraldesktop/api-php/pulls/comments{/number}","comments_url":"https://api.github.com/repos/centraldesktop/api-php/issues/1/comments","statuses_url":"https://api.github.com/repos/centraldesktop/api-php/statuses/58aff4e9bbc1a30e3986261843fcae4333ed2fed","head":{"label":"centraldesktop:initial","ref":"initial","sha":"58aff4e9bbc1a30e3986261843fcae4333ed2fed","user":{"login":"centraldesktop","id":148949,"avatar_url":"https://avatars.githubusercontent.com/u/148949?v=3","gravatar_id":"","url":"https://api.github.com/users/centraldesktop","html_url":"https://github.com/centraldesktop","followers_url":"https://api.github.com/users/centraldesktop/followers","following_url":"https://api.github.com/users/centraldesktop/following{/other_user}","gists_url":"https://api.github.com/users/centraldesktop/gists{/gist_id}","starred_url":"https://api.github.com/users/centraldesktop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/centraldesktop/subscriptions","organizations_url":"https://api.github.com/users/centraldesktop/orgs","repos_url":"https://api.github.com/users/centraldesktop/repos","events_url":"https://api.github.com/users/centraldesktop/events{/privacy}","received_events_url":"https://api.github.com/users/centraldesktop/received_events","type":"Organization","site_admin":false},"repo":{"id":39476310,"name":"api-php","full_name":"centraldesktop/api-php","owner":{"login":"centraldesktop","id":148949,"avatar_url":"https://avatars.githubusercontent.com/u/148949?v=3","gravatar_id":"","url":"https://api.github.com/users/centraldesktop","html_url":"https://github.com/centraldesktop","followers_url":"https://api.github.com/users/centraldesktop/followers","following_url":"https://api.github.com/users/centraldesktop/following{/other_user}","gists_url":"https://api.github.com/users/centraldesktop/gists{/gist_id}","starred_url":"https://api.github.com/users/centraldesktop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/centraldesktop/subscriptions","organizations_url":"https://api.github.com/users/centraldesktop/orgs","repos_url":"https://api.github.com/users/centraldesktop/repos","events_url":"https://api.github.com/users/centraldesktop/events{/privacy}","received_events_url":"https://api.github.com/users/centraldesktop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/centraldesktop/api-php","description":"PHP Sample code","fork":false,"url":"https://api.github.com/repos/centraldesktop/api-php","forks_url":"https://api.github.com/repos/centraldesktop/api-php/forks","keys_url":"https://api.github.com/repos/centraldesktop/api-php/keys{/key_id}","collaborators_url":"https://api.github.com/repos/centraldesktop/api-php/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/centraldesktop/api-php/teams","hooks_url":"https://api.github.com/repos/centraldesktop/api-php/hooks","issue_events_url":"https://api.github.com/repos/centraldesktop/api-php/issues/events{/number}","events_url":"https://api.github.com/repos/centraldesktop/api-php/events","assignees_url":"https://api.github.com/repos/centraldesktop/api-php/assignees{/user}","branches_url":"https://api.github.com/repos/centraldesktop/api-php/branches{/branch}","tags_url":"https://api.github.com/repos/centraldesktop/api-php/tags","blobs_url":"https://api.github.com/repos/centraldesktop/api-php/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/centraldesktop/api-php/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/centraldesktop/api-php/git/refs{/sha}","trees_url":"https://api.github.com/repos/centraldesktop/api-php/git/trees{/sha}","statuses_url":"https://api.github.com/repos/centraldesktop/api-php/statuses/{sha}","languages_url":"https://api.github.com/repos/centraldesktop/api-php/languages","stargazers_url":"https://api.github.com/repos/centraldesktop/api-php/stargazers","contributors_url":"https://api.github.com/repos/centraldesktop/api-php/contributors","subscribers_url":"https://api.github.com/repos/centraldesktop/api-php/subscribers","subscription_url":"https://api.github.com/repos/centraldesktop/api-php/subscription","commits_url":"https://api.github.com/repos/centraldesktop/api-php/commits{/sha}","git_commits_url":"https://api.github.com/repos/centraldesktop/api-php/git/commits{/sha}","comments_url":"https://api.github.com/repos/centraldesktop/api-php/comments{/number}","issue_comment_url":"https://api.github.com/repos/centraldesktop/api-php/issues/comments{/number}","contents_url":"https://api.github.com/repos/centraldesktop/api-php/contents/{+path}","compare_url":"https://api.github.com/repos/centraldesktop/api-php/compare/{base}...{head}","merges_url":"https://api.github.com/repos/centraldesktop/api-php/merges","archive_url":"https://api.github.com/repos/centraldesktop/api-php/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/centraldesktop/api-php/downloads","issues_url":"https://api.github.com/repos/centraldesktop/api-php/issues{/number}","pulls_url":"https://api.github.com/repos/centraldesktop/api-php/pulls{/number}","milestones_url":"https://api.github.com/repos/centraldesktop/api-php/milestones{/number}","notifications_url":"https://api.github.com/repos/centraldesktop/api-php/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/centraldesktop/api-php/labels{/name}","releases_url":"https://api.github.com/repos/centraldesktop/api-php/releases{/id}","created_at":"2015-07-22T00:16:05Z","updated_at":"2015-07-22T00:16:05Z","pushed_at":"2015-07-22T01:58:06Z","git_url":"git://github.com/centraldesktop/api-php.git","ssh_url":"git@github.com:centraldesktop/api-php.git","clone_url":"https://github.com/centraldesktop/api-php.git","svn_url":"https://github.com/centraldesktop/api-php","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"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":"centraldesktop:master","ref":"master","sha":"2fb0af26a4572af5f9795b5f98007f3fffccc86e","user":{"login":"centraldesktop","id":148949,"avatar_url":"https://avatars.githubusercontent.com/u/148949?v=3","gravatar_id":"","url":"https://api.github.com/users/centraldesktop","html_url":"https://github.com/centraldesktop","followers_url":"https://api.github.com/users/centraldesktop/followers","following_url":"https://api.github.com/users/centraldesktop/following{/other_user}","gists_url":"https://api.github.com/users/centraldesktop/gists{/gist_id}","starred_url":"https://api.github.com/users/centraldesktop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/centraldesktop/subscriptions","organizations_url":"https://api.github.com/users/centraldesktop/orgs","repos_url":"https://api.github.com/users/centraldesktop/repos","events_url":"https://api.github.com/users/centraldesktop/events{/privacy}","received_events_url":"https://api.github.com/users/centraldesktop/received_events","type":"Organization","site_admin":false},"repo":{"id":39476310,"name":"api-php","full_name":"centraldesktop/api-php","owner":{"login":"centraldesktop","id":148949,"avatar_url":"https://avatars.githubusercontent.com/u/148949?v=3","gravatar_id":"","url":"https://api.github.com/users/centraldesktop","html_url":"https://github.com/centraldesktop","followers_url":"https://api.github.com/users/centraldesktop/followers","following_url":"https://api.github.com/users/centraldesktop/following{/other_user}","gists_url":"https://api.github.com/users/centraldesktop/gists{/gist_id}","starred_url":"https://api.github.com/users/centraldesktop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/centraldesktop/subscriptions","organizations_url":"https://api.github.com/users/centraldesktop/orgs","repos_url":"https://api.github.com/users/centraldesktop/repos","events_url":"https://api.github.com/users/centraldesktop/events{/privacy}","received_events_url":"https://api.github.com/users/centraldesktop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/centraldesktop/api-php","description":"PHP Sample code","fork":false,"url":"https://api.github.com/repos/centraldesktop/api-php","forks_url":"https://api.github.com/repos/centraldesktop/api-php/forks","keys_url":"https://api.github.com/repos/centraldesktop/api-php/keys{/key_id}","collaborators_url":"https://api.github.com/repos/centraldesktop/api-php/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/centraldesktop/api-php/teams","hooks_url":"https://api.github.com/repos/centraldesktop/api-php/hooks","issue_events_url":"https://api.github.com/repos/centraldesktop/api-php/issues/events{/number}","events_url":"https://api.github.com/repos/centraldesktop/api-php/events","assignees_url":"https://api.github.com/repos/centraldesktop/api-php/assignees{/user}","branches_url":"https://api.github.com/repos/centraldesktop/api-php/branches{/branch}","tags_url":"https://api.github.com/repos/centraldesktop/api-php/tags","blobs_url":"https://api.github.com/repos/centraldesktop/api-php/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/centraldesktop/api-php/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/centraldesktop/api-php/git/refs{/sha}","trees_url":"https://api.github.com/repos/centraldesktop/api-php/git/trees{/sha}","statuses_url":"https://api.github.com/repos/centraldesktop/api-php/statuses/{sha}","languages_url":"https://api.github.com/repos/centraldesktop/api-php/languages","stargazers_url":"https://api.github.com/repos/centraldesktop/api-php/stargazers","contributors_url":"https://api.github.com/repos/centraldesktop/api-php/contributors","subscribers_url":"https://api.github.com/repos/centraldesktop/api-php/subscribers","subscription_url":"https://api.github.com/repos/centraldesktop/api-php/subscription","commits_url":"https://api.github.com/repos/centraldesktop/api-php/commits{/sha}","git_commits_url":"https://api.github.com/repos/centraldesktop/api-php/git/commits{/sha}","comments_url":"https://api.github.com/repos/centraldesktop/api-php/comments{/number}","issue_comment_url":"https://api.github.com/repos/centraldesktop/api-php/issues/comments{/number}","contents_url":"https://api.github.com/repos/centraldesktop/api-php/contents/{+path}","compare_url":"https://api.github.com/repos/centraldesktop/api-php/compare/{base}...{head}","merges_url":"https://api.github.com/repos/centraldesktop/api-php/merges","archive_url":"https://api.github.com/repos/centraldesktop/api-php/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/centraldesktop/api-php/downloads","issues_url":"https://api.github.com/repos/centraldesktop/api-php/issues{/number}","pulls_url":"https://api.github.com/repos/centraldesktop/api-php/pulls{/number}","milestones_url":"https://api.github.com/repos/centraldesktop/api-php/milestones{/number}","notifications_url":"https://api.github.com/repos/centraldesktop/api-php/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/centraldesktop/api-php/labels{/name}","releases_url":"https://api.github.com/repos/centraldesktop/api-php/releases{/id}","created_at":"2015-07-22T00:16:05Z","updated_at":"2015-07-22T00:16:05Z","pushed_at":"2015-07-22T01:58:06Z","git_url":"git://github.com/centraldesktop/api-php.git","ssh_url":"git@github.com:centraldesktop/api-php.git","clone_url":"https://github.com/centraldesktop/api-php.git","svn_url":"https://github.com/centraldesktop/api-php","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"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/centraldesktop/api-php/pulls/1"},"html":{"href":"https://github.com/centraldesktop/api-php/pull/1"},"issue":{"href":"https://api.github.com/repos/centraldesktop/api-php/issues/1"},"comments":{"href":"https://api.github.com/repos/centraldesktop/api-php/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/centraldesktop/api-php/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/centraldesktop/api-php/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/centraldesktop/api-php/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/centraldesktop/api-php/statuses/58aff4e9bbc1a30e3986261843fcae4333ed2fed"}}}}