{"action":"created","comment":{"url":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/comments/41584421","id":41584421,"diff_hunk":"@@ -75,69 +78,112 @@\n \n \t['get', 'post', 'put', 'patch', 'delete', 'options'].forEach(function(method) {\n \t    Monocle.prototype[method] = function(path, options) {\n-\t        switch (method) {\n-\t            // Check cache if attempting to get resource\n-\t            case 'get':\n-\t                var cached = this._cache.get(path);\n-\t                if (cached) {\n-\t                    if (!options.props) {\n-\t                        return Promise.resolve(cached);\n-\t                    }\n-\t                    var found = true;\n-\t                    for (var i in options.props) {\n-\t                        if (!cached.hasOwnProperty(options.props[i])) {\n-\t                            this._cache.remove(path);\n-\t                            found = false;\n-\t                            break;\n-\t                        }\n-\t                    }\n-\t                    if (found) return Promise.resolve(cached);\n-\t                }\n-\t                break;\n-\n-\t            // Remove from cache when resource is being updated or removed\n-\t            case 'post':\n-\t            case 'put':\n-\t            case 'delete':\n-\t            case 'patch':\n-\t                this._cache.remove(path);\n-\t                break;\n-\t        }\n+\t        return _handle.call(this, method, path, options);\n+\t    };\n+\t});\n \n-\t        var fullPath = buildFullPath(this._base, path);\n-\t        var query = buildQuery(options);\n+\tvar updateBatchTimeout = function() {\n+\t    if (null !== this._batchTimeout) {\n+\t        // Batch timeout already set up, nothing to do.\n+\t        return;\n+\t    }\n \n-\t        if (query) fullPath += '?' + query;\n+\t    this._batchTimeout = setTimeout(function() {\n+\t        processBatch.call(this);\n+\t        this._batchTimeout = null;\n+\t    }.bind(this));\n+\t};\n \n-\t        return this._http.request(method.toUpperCase(), fullPath, options)\n-\t        .then(cacheResource.bind(this, method));\n-\t    };\n+\tvar processBatch = function() {\n+\t    var batched = this._batched;\n+\t    this._batched = [];\n \n-\t    var cacheResource = function(method, resource) {\n-\t        if ('get' === method && resource.$id && resource.$expires) {\n-\t            this._cache.put(resource.$id, resource, resource.$expires);\n-\t        }\n-\t        return resource;\n-\t    };\n+\t    if (1 === batched.length) {\n+\t        var fullPath = buildFullPath(this._base, batched[0].url);\n+\t        var query = buildQuery(batched[0].options);\n \n-\t    var buildFullPath = function(base, path) {\n-\t        return (base + path).replace(/\\/{2,}/g, '/');\n-\t    };\n+\t        if (query) fullPath += '?' + query;\n \n-\t    function buildQuery(options) {\n-\t        var query = {};\n+\t        return this._http.request(batched[0].method.toUpperCase(), fullPath, batched[0].options)\n+\t        .then(batched[0].resolve)\n+\t        .catch(batched[0].reject);\n+\t    }\n \n-\t        if (options && Array.isArray(options.props)) query.props = options.props.join(',');\n+\t    return this._http.request('POST', buildFullPath(this._base, '/_batch'), {\n+\t        body: batched\n+\t    }).then(function(results) {\n+\t        results.forEach(function(result, i) {\n+\t            if (result.status >= 200 && result.status < 300) {\n+\t                batched[i].resolve(result.body);\n+\t            } else {\n+\t                batched[i].reject(result.body);\n+\t            }\n+\t        })\n+\t    }).catch(function(error) {\n+\t        batched.forEach(function(apiCall, i) {\n+\t            batched[i].reject(error);\n+\t        });\n+\t    });\n+\t};\n \n-\t        var queryStringParts = [];\n+\tvar _handle = function(method, path, options) {\n+\t    switch (method) {","path":"demo/public/monocle-client-angular.js","position":124,"original_position":124,"commit_id":"7c4b49ca0724d8d5926d416c49604dee61ce7636","original_commit_id":"7c4b49ca0724d8d5926d416c49604dee61ce7636","user":{"login":"marianeaj","id":1957504,"avatar_url":"https://avatars.githubusercontent.com/u/1957504?v=3","gravatar_id":"","url":"https://api.github.com/users/marianeaj","html_url":"https://github.com/marianeaj","followers_url":"https://api.github.com/users/marianeaj/followers","following_url":"https://api.github.com/users/marianeaj/following{/other_user}","gists_url":"https://api.github.com/users/marianeaj/gists{/gist_id}","starred_url":"https://api.github.com/users/marianeaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marianeaj/subscriptions","organizations_url":"https://api.github.com/users/marianeaj/orgs","repos_url":"https://api.github.com/users/marianeaj/repos","events_url":"https://api.github.com/users/marianeaj/events{/privacy}","received_events_url":"https://api.github.com/users/marianeaj/received_events","type":"User","site_admin":false},"body":"should we make this check case insensitive?","created_at":"2015-10-08T23:49:50Z","updated_at":"2015-10-08T23:49:50Z","html_url":"https://github.com/ifwe/monocle-client-js/pull/4#discussion_r41584421","pull_request_url":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/comments/41584421"},"html":{"href":"https://github.com/ifwe/monocle-client-js/pull/4#discussion_r41584421"},"pull_request":{"href":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/4","id":47087483,"html_url":"https://github.com/ifwe/monocle-client-js/pull/4","diff_url":"https://github.com/ifwe/monocle-client-js/pull/4.diff","patch_url":"https://github.com/ifwe/monocle-client-js/pull/4.patch","issue_url":"https://api.github.com/repos/ifwe/monocle-client-js/issues/4","number":4,"state":"open","locked":false,"title":"Feature/batch calls","user":{"login":"djvirgen","id":308786,"avatar_url":"https://avatars.githubusercontent.com/u/308786?v=3","gravatar_id":"","url":"https://api.github.com/users/djvirgen","html_url":"https://github.com/djvirgen","followers_url":"https://api.github.com/users/djvirgen/followers","following_url":"https://api.github.com/users/djvirgen/following{/other_user}","gists_url":"https://api.github.com/users/djvirgen/gists{/gist_id}","starred_url":"https://api.github.com/users/djvirgen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djvirgen/subscriptions","organizations_url":"https://api.github.com/users/djvirgen/orgs","repos_url":"https://api.github.com/users/djvirgen/repos","events_url":"https://api.github.com/users/djvirgen/events{/privacy}","received_events_url":"https://api.github.com/users/djvirgen/received_events","type":"User","site_admin":false},"body":"Use batch endpoint if multiple calls are made at the same time (before the next tick).","created_at":"2015-10-07T21:54:51Z","updated_at":"2015-10-08T23:49:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"00dab31a6a3f4016e48ff591bf1988969396d615","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/4/commits","review_comments_url":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/4/comments","review_comment_url":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ifwe/monocle-client-js/issues/4/comments","statuses_url":"https://api.github.com/repos/ifwe/monocle-client-js/statuses/7c4b49ca0724d8d5926d416c49604dee61ce7636","head":{"label":"ifwe:feature/batch-calls","ref":"feature/batch-calls","sha":"7c4b49ca0724d8d5926d416c49604dee61ce7636","user":{"login":"ifwe","id":8762479,"avatar_url":"https://avatars.githubusercontent.com/u/8762479?v=3","gravatar_id":"","url":"https://api.github.com/users/ifwe","html_url":"https://github.com/ifwe","followers_url":"https://api.github.com/users/ifwe/followers","following_url":"https://api.github.com/users/ifwe/following{/other_user}","gists_url":"https://api.github.com/users/ifwe/gists{/gist_id}","starred_url":"https://api.github.com/users/ifwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifwe/subscriptions","organizations_url":"https://api.github.com/users/ifwe/orgs","repos_url":"https://api.github.com/users/ifwe/repos","events_url":"https://api.github.com/users/ifwe/events{/privacy}","received_events_url":"https://api.github.com/users/ifwe/received_events","type":"Organization","site_admin":false},"repo":{"id":43386264,"name":"monocle-client-js","full_name":"ifwe/monocle-client-js","owner":{"login":"ifwe","id":8762479,"avatar_url":"https://avatars.githubusercontent.com/u/8762479?v=3","gravatar_id":"","url":"https://api.github.com/users/ifwe","html_url":"https://github.com/ifwe","followers_url":"https://api.github.com/users/ifwe/followers","following_url":"https://api.github.com/users/ifwe/following{/other_user}","gists_url":"https://api.github.com/users/ifwe/gists{/gist_id}","starred_url":"https://api.github.com/users/ifwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifwe/subscriptions","organizations_url":"https://api.github.com/users/ifwe/orgs","repos_url":"https://api.github.com/users/ifwe/repos","events_url":"https://api.github.com/users/ifwe/events{/privacy}","received_events_url":"https://api.github.com/users/ifwe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ifwe/monocle-client-js","description":"Monocle API Client for Node and Angular","fork":false,"url":"https://api.github.com/repos/ifwe/monocle-client-js","forks_url":"https://api.github.com/repos/ifwe/monocle-client-js/forks","keys_url":"https://api.github.com/repos/ifwe/monocle-client-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ifwe/monocle-client-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ifwe/monocle-client-js/teams","hooks_url":"https://api.github.com/repos/ifwe/monocle-client-js/hooks","issue_events_url":"https://api.github.com/repos/ifwe/monocle-client-js/issues/events{/number}","events_url":"https://api.github.com/repos/ifwe/monocle-client-js/events","assignees_url":"https://api.github.com/repos/ifwe/monocle-client-js/assignees{/user}","branches_url":"https://api.github.com/repos/ifwe/monocle-client-js/branches{/branch}","tags_url":"https://api.github.com/repos/ifwe/monocle-client-js/tags","blobs_url":"https://api.github.com/repos/ifwe/monocle-client-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ifwe/monocle-client-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ifwe/monocle-client-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/ifwe/monocle-client-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ifwe/monocle-client-js/statuses/{sha}","languages_url":"https://api.github.com/repos/ifwe/monocle-client-js/languages","stargazers_url":"https://api.github.com/repos/ifwe/monocle-client-js/stargazers","contributors_url":"https://api.github.com/repos/ifwe/monocle-client-js/contributors","subscribers_url":"https://api.github.com/repos/ifwe/monocle-client-js/subscribers","subscription_url":"https://api.github.com/repos/ifwe/monocle-client-js/subscription","commits_url":"https://api.github.com/repos/ifwe/monocle-client-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/ifwe/monocle-client-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/ifwe/monocle-client-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/ifwe/monocle-client-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/ifwe/monocle-client-js/contents/{+path}","compare_url":"https://api.github.com/repos/ifwe/monocle-client-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ifwe/monocle-client-js/merges","archive_url":"https://api.github.com/repos/ifwe/monocle-client-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ifwe/monocle-client-js/downloads","issues_url":"https://api.github.com/repos/ifwe/monocle-client-js/issues{/number}","pulls_url":"https://api.github.com/repos/ifwe/monocle-client-js/pulls{/number}","milestones_url":"https://api.github.com/repos/ifwe/monocle-client-js/milestones{/number}","notifications_url":"https://api.github.com/repos/ifwe/monocle-client-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ifwe/monocle-client-js/labels{/name}","releases_url":"https://api.github.com/repos/ifwe/monocle-client-js/releases{/id}","created_at":"2015-09-29T18:28:04Z","updated_at":"2015-09-29T18:28:30Z","pushed_at":"2015-10-08T21:27:56Z","git_url":"git://github.com/ifwe/monocle-client-js.git","ssh_url":"git@github.com:ifwe/monocle-client-js.git","clone_url":"https://github.com/ifwe/monocle-client-js.git","svn_url":"https://github.com/ifwe/monocle-client-js","homepage":null,"size":492,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"ifwe:master","ref":"master","sha":"082e54bb65338aefe2b15a8d2c462a653dff2164","user":{"login":"ifwe","id":8762479,"avatar_url":"https://avatars.githubusercontent.com/u/8762479?v=3","gravatar_id":"","url":"https://api.github.com/users/ifwe","html_url":"https://github.com/ifwe","followers_url":"https://api.github.com/users/ifwe/followers","following_url":"https://api.github.com/users/ifwe/following{/other_user}","gists_url":"https://api.github.com/users/ifwe/gists{/gist_id}","starred_url":"https://api.github.com/users/ifwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifwe/subscriptions","organizations_url":"https://api.github.com/users/ifwe/orgs","repos_url":"https://api.github.com/users/ifwe/repos","events_url":"https://api.github.com/users/ifwe/events{/privacy}","received_events_url":"https://api.github.com/users/ifwe/received_events","type":"Organization","site_admin":false},"repo":{"id":43386264,"name":"monocle-client-js","full_name":"ifwe/monocle-client-js","owner":{"login":"ifwe","id":8762479,"avatar_url":"https://avatars.githubusercontent.com/u/8762479?v=3","gravatar_id":"","url":"https://api.github.com/users/ifwe","html_url":"https://github.com/ifwe","followers_url":"https://api.github.com/users/ifwe/followers","following_url":"https://api.github.com/users/ifwe/following{/other_user}","gists_url":"https://api.github.com/users/ifwe/gists{/gist_id}","starred_url":"https://api.github.com/users/ifwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifwe/subscriptions","organizations_url":"https://api.github.com/users/ifwe/orgs","repos_url":"https://api.github.com/users/ifwe/repos","events_url":"https://api.github.com/users/ifwe/events{/privacy}","received_events_url":"https://api.github.com/users/ifwe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ifwe/monocle-client-js","description":"Monocle API Client for Node and Angular","fork":false,"url":"https://api.github.com/repos/ifwe/monocle-client-js","forks_url":"https://api.github.com/repos/ifwe/monocle-client-js/forks","keys_url":"https://api.github.com/repos/ifwe/monocle-client-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ifwe/monocle-client-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ifwe/monocle-client-js/teams","hooks_url":"https://api.github.com/repos/ifwe/monocle-client-js/hooks","issue_events_url":"https://api.github.com/repos/ifwe/monocle-client-js/issues/events{/number}","events_url":"https://api.github.com/repos/ifwe/monocle-client-js/events","assignees_url":"https://api.github.com/repos/ifwe/monocle-client-js/assignees{/user}","branches_url":"https://api.github.com/repos/ifwe/monocle-client-js/branches{/branch}","tags_url":"https://api.github.com/repos/ifwe/monocle-client-js/tags","blobs_url":"https://api.github.com/repos/ifwe/monocle-client-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ifwe/monocle-client-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ifwe/monocle-client-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/ifwe/monocle-client-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ifwe/monocle-client-js/statuses/{sha}","languages_url":"https://api.github.com/repos/ifwe/monocle-client-js/languages","stargazers_url":"https://api.github.com/repos/ifwe/monocle-client-js/stargazers","contributors_url":"https://api.github.com/repos/ifwe/monocle-client-js/contributors","subscribers_url":"https://api.github.com/repos/ifwe/monocle-client-js/subscribers","subscription_url":"https://api.github.com/repos/ifwe/monocle-client-js/subscription","commits_url":"https://api.github.com/repos/ifwe/monocle-client-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/ifwe/monocle-client-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/ifwe/monocle-client-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/ifwe/monocle-client-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/ifwe/monocle-client-js/contents/{+path}","compare_url":"https://api.github.com/repos/ifwe/monocle-client-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ifwe/monocle-client-js/merges","archive_url":"https://api.github.com/repos/ifwe/monocle-client-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ifwe/monocle-client-js/downloads","issues_url":"https://api.github.com/repos/ifwe/monocle-client-js/issues{/number}","pulls_url":"https://api.github.com/repos/ifwe/monocle-client-js/pulls{/number}","milestones_url":"https://api.github.com/repos/ifwe/monocle-client-js/milestones{/number}","notifications_url":"https://api.github.com/repos/ifwe/monocle-client-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ifwe/monocle-client-js/labels{/name}","releases_url":"https://api.github.com/repos/ifwe/monocle-client-js/releases{/id}","created_at":"2015-09-29T18:28:04Z","updated_at":"2015-09-29T18:28:30Z","pushed_at":"2015-10-08T21:27:56Z","git_url":"git://github.com/ifwe/monocle-client-js.git","ssh_url":"git@github.com:ifwe/monocle-client-js.git","clone_url":"https://github.com/ifwe/monocle-client-js.git","svn_url":"https://github.com/ifwe/monocle-client-js","homepage":null,"size":492,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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/ifwe/monocle-client-js/pulls/4"},"html":{"href":"https://github.com/ifwe/monocle-client-js/pull/4"},"issue":{"href":"https://api.github.com/repos/ifwe/monocle-client-js/issues/4"},"comments":{"href":"https://api.github.com/repos/ifwe/monocle-client-js/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ifwe/monocle-client-js/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/ifwe/monocle-client-js/statuses/7c4b49ca0724d8d5926d416c49604dee61ce7636"}}}}