{"action":"created","comment":{"url":"https://api.github.com/repos/tadatuta/bem-forum/pulls/comments/108047526","pull_request_review_id":29058261,"id":108047526,"diff_hunk":"@@ -0,0 +1,142 @@\n+/**\n+ * @module api-request\n+ */\n+modules.define('api-request', [\n+    'jquery', 'uri__querystring', 'store'\n+], function(provide, $, Querystring, store) {\n+\n+    /**\n+     * Делает fetch запрос в АПИ\n+     * @param {String} apiPath - путь к API наичнающийся без '/'\n+     * @param {Object} ajaxSettings - JQuery.AjaxSettings\n+     * @param {*} context - контекст выполнения колбеков (deprecated, instead use arrow functions)\n+     * @returns {Request}\n+     */\n+    function request(apiPath, ajaxSettings, context) {\n+        const settings = request._prepareSettings(ajaxSettings || {});\n+        let url = request._basePath + apiPath;\n+\n+        if (context) {\n+            settings.context = context;\n+        }\n+\n+        if (settings.query) {\n+            const qs = Querystring.stringify(settings.query);\n+\n+            delete settings.query;\n+\n+            url += (url.includes('?') ? '&' : '?') + qs;\n+        }\n+\n+        return fetch(url, settings).then(checkStatus);\n+    }\n+\n+    /**\n+     * Сахар для совершения POST запросов.\n+     * @param {String} apiPath - путь к API наичнающийся без '/'\n+     * @param {Object} data - JSON сериализуемый объект, для передач на сервер\n+     * @param {*} [context] - контекст выполнения колбеков (deprecated, instead use arrow functions)\n+     * @returns {Request}\n+     */\n+    request.post = function(apiPath, data, context) {\n+        return request(apiPath, {\n+            method: 'POST',\n+            body: data\n+        }, context);\n+    };\n+\n+    /**\n+     * Сахар для совершения PUT запросов.\n+     * @param {String} apiPath - путь к API наичнающийся без '/'\n+     * @param {Object} data - JSON сериализуемый объект, для передач на сервер\n+     * @param {*} [context] - контекст выполнения колбеков (deprecated, instead use arrow functions)\n+     * @returns {Request}\n+     */\n+    request.put = function(apiPath, data, context) {\n+        return request(apiPath, {\n+            method: 'PUT',\n+            body: data\n+        }, context);\n+    };\n+\n+    /**\n+     * Запрос на удаление с методом DELETE\n+     * @param {String} apiPath - путь к API наичнающийся без '/'\n+     * @param {Object} [data] - JSON сериализуемый объект, для передач на сервер\n+     * @param {*} [context] - контекст выполнения колбеков (deprecated, instead use arrow functions)\n+     * @returns {Request}\n+     */\n+    request.delete = function(apiPath, data, context) {\n+        return request(apiPath, {\n+            method: 'DELETE',\n+            body: data\n+        }, context);\n+    };\n+\n+    /**\n+     * Добавляет разные плюшки к настройкам запроса:\n+     *  - Если body это объект, то добавляет contentType и сериализует объект.\n+     * @param {Object} settings - fetch AjaxSettings\n+     * @returns {Object}\n+     * @private\n+     */\n+    request._prepareSettings = function(settings = {}) {\n+        const query = Querystring.parse(window.location.search.substring(1));\n+        const headers = settings.headers || {};\n+\n+        if (!headers['content-type'] && $.isPlainObject(settings.body)) {\n+            headers['content-type'] = 'application/json; charset=UTF-8';\n+            settings.body = JSON.stringify(settings.body);\n+        }\n+\n+        // Если в поле Body придут пустые данные или же undefined то надо удалить это поле.\n+        if (!settings.body) {\n+            delete settings.body;\n+        }\n+\n+        if (settings.method && settings.method.toUpperCase() !== 'GET') {\n+            headers['x-csrf-token'] = store.getData().csrf;\n+        }\n+\n+        settings.query || (settings.query = {});\n+        if (!settings.query.locale && query.locale) {\n+            settings.query.locale = query.locale;\n+        }\n+\n+        if (!settings.query.auth && query.auth) {\n+            settings.query.auth = query.auth;\n+        }\n+\n+        if (!settings.credentials) {\n+            settings.credentials = 'same-origin';\n+        }\n+        Object.keys(headers).length > 0 && (settings.headers = headers);\n+\n+        return settings;\n+    };\n+\n+    /**\n+     * Префикс приложения\n+     * @type {string}\n+     * @private\n+     */\n+    request._basePath = '/api/';","path":"common.blocks/api-request/api-request.js","position":123,"original_position":123,"commit_id":"bfb9c4a7d65e53bda396d890b739d657a8853889","original_commit_id":"bfb9c4a7d65e53bda396d890b739d657a8853889","user":{"login":"birhoff","id":2110357,"avatar_url":"https://avatars2.githubusercontent.com/u/2110357?v=3","gravatar_id":"","url":"https://api.github.com/users/birhoff","html_url":"https://github.com/birhoff","followers_url":"https://api.github.com/users/birhoff/followers","following_url":"https://api.github.com/users/birhoff/following{/other_user}","gists_url":"https://api.github.com/users/birhoff/gists{/gist_id}","starred_url":"https://api.github.com/users/birhoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/birhoff/subscriptions","organizations_url":"https://api.github.com/users/birhoff/orgs","repos_url":"https://api.github.com/users/birhoff/repos","events_url":"https://api.github.com/users/birhoff/events{/privacy}","received_events_url":"https://api.github.com/users/birhoff/received_events","type":"User","site_admin":false},"body":"Это не префикс приложения, а API префикс","created_at":"2017-03-25T23:07:57Z","updated_at":"2017-03-25T23:07:57Z","html_url":"https://github.com/tadatuta/bem-forum/pull/27#discussion_r108047526","pull_request_url":"https://api.github.com/repos/tadatuta/bem-forum/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/tadatuta/bem-forum/pulls/comments/108047526"},"html":{"href":"https://github.com/tadatuta/bem-forum/pull/27#discussion_r108047526"},"pull_request":{"href":"https://api.github.com/repos/tadatuta/bem-forum/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/tadatuta/bem-forum/pulls/27","id":112589819,"html_url":"https://github.com/tadatuta/bem-forum/pull/27","diff_url":"https://github.com/tadatuta/bem-forum/pull/27.diff","patch_url":"https://github.com/tadatuta/bem-forum/pull/27.patch","issue_url":"https://api.github.com/repos/tadatuta/bem-forum/issues/27","number":27,"state":"open","locked":false,"title":"Store","user":{"login":"skad0","id":974119,"avatar_url":"https://avatars1.githubusercontent.com/u/974119?v=3","gravatar_id":"","url":"https://api.github.com/users/skad0","html_url":"https://github.com/skad0","followers_url":"https://api.github.com/users/skad0/followers","following_url":"https://api.github.com/users/skad0/following{/other_user}","gists_url":"https://api.github.com/users/skad0/gists{/gist_id}","starred_url":"https://api.github.com/users/skad0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skad0/subscriptions","organizations_url":"https://api.github.com/users/skad0/orgs","repos_url":"https://api.github.com/users/skad0/repos","events_url":"https://api.github.com/users/skad0/events{/privacy}","received_events_url":"https://api.github.com/users/skad0/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-25T15:14:58Z","updated_at":"2017-03-25T23:07:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9fa29aa77863e6a29f7811d3aa9b5bf897c6e8b2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tadatuta/bem-forum/pulls/27/commits","review_comments_url":"https://api.github.com/repos/tadatuta/bem-forum/pulls/27/comments","review_comment_url":"https://api.github.com/repos/tadatuta/bem-forum/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tadatuta/bem-forum/issues/27/comments","statuses_url":"https://api.github.com/repos/tadatuta/bem-forum/statuses/bfb9c4a7d65e53bda396d890b739d657a8853889","head":{"label":"skad0:store","ref":"store","sha":"bfb9c4a7d65e53bda396d890b739d657a8853889","user":{"login":"skad0","id":974119,"avatar_url":"https://avatars1.githubusercontent.com/u/974119?v=3","gravatar_id":"","url":"https://api.github.com/users/skad0","html_url":"https://github.com/skad0","followers_url":"https://api.github.com/users/skad0/followers","following_url":"https://api.github.com/users/skad0/following{/other_user}","gists_url":"https://api.github.com/users/skad0/gists{/gist_id}","starred_url":"https://api.github.com/users/skad0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skad0/subscriptions","organizations_url":"https://api.github.com/users/skad0/orgs","repos_url":"https://api.github.com/users/skad0/repos","events_url":"https://api.github.com/users/skad0/events{/privacy}","received_events_url":"https://api.github.com/users/skad0/received_events","type":"User","site_admin":false},"repo":{"id":74839193,"name":"bem-forum","full_name":"skad0/bem-forum","owner":{"login":"skad0","id":974119,"avatar_url":"https://avatars1.githubusercontent.com/u/974119?v=3","gravatar_id":"","url":"https://api.github.com/users/skad0","html_url":"https://github.com/skad0","followers_url":"https://api.github.com/users/skad0/followers","following_url":"https://api.github.com/users/skad0/following{/other_user}","gists_url":"https://api.github.com/users/skad0/gists{/gist_id}","starred_url":"https://api.github.com/users/skad0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skad0/subscriptions","organizations_url":"https://api.github.com/users/skad0/orgs","repos_url":"https://api.github.com/users/skad0/repos","events_url":"https://api.github.com/users/skad0/events{/privacy}","received_events_url":"https://api.github.com/users/skad0/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/skad0/bem-forum","description":null,"fork":true,"url":"https://api.github.com/repos/skad0/bem-forum","forks_url":"https://api.github.com/repos/skad0/bem-forum/forks","keys_url":"https://api.github.com/repos/skad0/bem-forum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/skad0/bem-forum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/skad0/bem-forum/teams","hooks_url":"https://api.github.com/repos/skad0/bem-forum/hooks","issue_events_url":"https://api.github.com/repos/skad0/bem-forum/issues/events{/number}","events_url":"https://api.github.com/repos/skad0/bem-forum/events","assignees_url":"https://api.github.com/repos/skad0/bem-forum/assignees{/user}","branches_url":"https://api.github.com/repos/skad0/bem-forum/branches{/branch}","tags_url":"https://api.github.com/repos/skad0/bem-forum/tags","blobs_url":"https://api.github.com/repos/skad0/bem-forum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/skad0/bem-forum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/skad0/bem-forum/git/refs{/sha}","trees_url":"https://api.github.com/repos/skad0/bem-forum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/skad0/bem-forum/statuses/{sha}","languages_url":"https://api.github.com/repos/skad0/bem-forum/languages","stargazers_url":"https://api.github.com/repos/skad0/bem-forum/stargazers","contributors_url":"https://api.github.com/repos/skad0/bem-forum/contributors","subscribers_url":"https://api.github.com/repos/skad0/bem-forum/subscribers","subscription_url":"https://api.github.com/repos/skad0/bem-forum/subscription","commits_url":"https://api.github.com/repos/skad0/bem-forum/commits{/sha}","git_commits_url":"https://api.github.com/repos/skad0/bem-forum/git/commits{/sha}","comments_url":"https://api.github.com/repos/skad0/bem-forum/comments{/number}","issue_comment_url":"https://api.github.com/repos/skad0/bem-forum/issues/comments{/number}","contents_url":"https://api.github.com/repos/skad0/bem-forum/contents/{+path}","compare_url":"https://api.github.com/repos/skad0/bem-forum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/skad0/bem-forum/merges","archive_url":"https://api.github.com/repos/skad0/bem-forum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/skad0/bem-forum/downloads","issues_url":"https://api.github.com/repos/skad0/bem-forum/issues{/number}","pulls_url":"https://api.github.com/repos/skad0/bem-forum/pulls{/number}","milestones_url":"https://api.github.com/repos/skad0/bem-forum/milestones{/number}","notifications_url":"https://api.github.com/repos/skad0/bem-forum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/skad0/bem-forum/labels{/name}","releases_url":"https://api.github.com/repos/skad0/bem-forum/releases{/id}","deployments_url":"https://api.github.com/repos/skad0/bem-forum/deployments","created_at":"2016-11-26T17:06:42Z","updated_at":"2016-11-26T17:06:43Z","pushed_at":"2017-03-25T18:57:57Z","git_url":"git://github.com/skad0/bem-forum.git","ssh_url":"git@github.com:skad0/bem-forum.git","clone_url":"https://github.com/skad0/bem-forum.git","svn_url":"https://github.com/skad0/bem-forum","homepage":null,"size":113,"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":"tadatuta:master","ref":"master","sha":"a74b5b5b97893ed66d4b73e6bfff82fb314326e7","user":{"login":"tadatuta","id":475746,"avatar_url":"https://avatars3.githubusercontent.com/u/475746?v=3","gravatar_id":"","url":"https://api.github.com/users/tadatuta","html_url":"https://github.com/tadatuta","followers_url":"https://api.github.com/users/tadatuta/followers","following_url":"https://api.github.com/users/tadatuta/following{/other_user}","gists_url":"https://api.github.com/users/tadatuta/gists{/gist_id}","starred_url":"https://api.github.com/users/tadatuta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tadatuta/subscriptions","organizations_url":"https://api.github.com/users/tadatuta/orgs","repos_url":"https://api.github.com/users/tadatuta/repos","events_url":"https://api.github.com/users/tadatuta/events{/privacy}","received_events_url":"https://api.github.com/users/tadatuta/received_events","type":"User","site_admin":false},"repo":{"id":62709287,"name":"bem-forum","full_name":"tadatuta/bem-forum","owner":{"login":"tadatuta","id":475746,"avatar_url":"https://avatars3.githubusercontent.com/u/475746?v=3","gravatar_id":"","url":"https://api.github.com/users/tadatuta","html_url":"https://github.com/tadatuta","followers_url":"https://api.github.com/users/tadatuta/followers","following_url":"https://api.github.com/users/tadatuta/following{/other_user}","gists_url":"https://api.github.com/users/tadatuta/gists{/gist_id}","starred_url":"https://api.github.com/users/tadatuta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tadatuta/subscriptions","organizations_url":"https://api.github.com/users/tadatuta/orgs","repos_url":"https://api.github.com/users/tadatuta/repos","events_url":"https://api.github.com/users/tadatuta/events{/privacy}","received_events_url":"https://api.github.com/users/tadatuta/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tadatuta/bem-forum","description":null,"fork":false,"url":"https://api.github.com/repos/tadatuta/bem-forum","forks_url":"https://api.github.com/repos/tadatuta/bem-forum/forks","keys_url":"https://api.github.com/repos/tadatuta/bem-forum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tadatuta/bem-forum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tadatuta/bem-forum/teams","hooks_url":"https://api.github.com/repos/tadatuta/bem-forum/hooks","issue_events_url":"https://api.github.com/repos/tadatuta/bem-forum/issues/events{/number}","events_url":"https://api.github.com/repos/tadatuta/bem-forum/events","assignees_url":"https://api.github.com/repos/tadatuta/bem-forum/assignees{/user}","branches_url":"https://api.github.com/repos/tadatuta/bem-forum/branches{/branch}","tags_url":"https://api.github.com/repos/tadatuta/bem-forum/tags","blobs_url":"https://api.github.com/repos/tadatuta/bem-forum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tadatuta/bem-forum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tadatuta/bem-forum/git/refs{/sha}","trees_url":"https://api.github.com/repos/tadatuta/bem-forum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tadatuta/bem-forum/statuses/{sha}","languages_url":"https://api.github.com/repos/tadatuta/bem-forum/languages","stargazers_url":"https://api.github.com/repos/tadatuta/bem-forum/stargazers","contributors_url":"https://api.github.com/repos/tadatuta/bem-forum/contributors","subscribers_url":"https://api.github.com/repos/tadatuta/bem-forum/subscribers","subscription_url":"https://api.github.com/repos/tadatuta/bem-forum/subscription","commits_url":"https://api.github.com/repos/tadatuta/bem-forum/commits{/sha}","git_commits_url":"https://api.github.com/repos/tadatuta/bem-forum/git/commits{/sha}","comments_url":"https://api.github.com/repos/tadatuta/bem-forum/comments{/number}","issue_comment_url":"https://api.github.com/repos/tadatuta/bem-forum/issues/comments{/number}","contents_url":"https://api.github.com/repos/tadatuta/bem-forum/contents/{+path}","compare_url":"https://api.github.com/repos/tadatuta/bem-forum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tadatuta/bem-forum/merges","archive_url":"https://api.github.com/repos/tadatuta/bem-forum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tadatuta/bem-forum/downloads","issues_url":"https://api.github.com/repos/tadatuta/bem-forum/issues{/number}","pulls_url":"https://api.github.com/repos/tadatuta/bem-forum/pulls{/number}","milestones_url":"https://api.github.com/repos/tadatuta/bem-forum/milestones{/number}","notifications_url":"https://api.github.com/repos/tadatuta/bem-forum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tadatuta/bem-forum/labels{/name}","releases_url":"https://api.github.com/repos/tadatuta/bem-forum/releases{/id}","deployments_url":"https://api.github.com/repos/tadatuta/bem-forum/deployments","created_at":"2016-07-06T09:35:45Z","updated_at":"2016-12-01T12:29:15Z","pushed_at":"2017-03-25T18:57:58Z","git_url":"git://github.com/tadatuta/bem-forum.git","ssh_url":"git@github.com:tadatuta/bem-forum.git","clone_url":"https://github.com/tadatuta/bem-forum.git","svn_url":"https://github.com/tadatuta/bem-forum","homepage":null,"size":62,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":15,"forks":6,"open_issues":15,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tadatuta/bem-forum/pulls/27"},"html":{"href":"https://github.com/tadatuta/bem-forum/pull/27"},"issue":{"href":"https://api.github.com/repos/tadatuta/bem-forum/issues/27"},"comments":{"href":"https://api.github.com/repos/tadatuta/bem-forum/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/tadatuta/bem-forum/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/tadatuta/bem-forum/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tadatuta/bem-forum/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/tadatuta/bem-forum/statuses/bfb9c4a7d65e53bda396d890b739d657a8853889"}}}}
{"actor":{"display_login":"birhoff"}}