diff --git a/lib/feedly.js b/lib/feedly.js index c5d286c..79858f2 100644 --- a/lib/feedly.js +++ b/lib/feedly.js @@ -1,3 +1,4 @@ +// Generated by CoffeeScript 1.10.0 (function() { var Feedly, _normalizeTag, fs, http, open, path, q, request, untildify, url, utils; @@ -55,14 +56,15 @@ return function(data) { var er, s; return _this.state = (function() { + var error; try { s = JSON.parse(data); if (s.expires != null) { s.expires = new Date(s.expires); } return s; - } catch (_error) { - er = _error; + } catch (error) { + er = error; return this.state = {}; } }).call(_this); @@ -510,13 +512,24 @@ return this._requestURL(cb, "/v3/streams/" + (encodeURIComponent(id)) + "/ids", 'GET', input); }; - Feedly.prototype.contents = function(id, continuation, cb) { + Feedly.prototype.contents = function(id, options, cb) { var input; - input = {}; - if (continuation != null) { - input.continuation = continuation; - } - return this._request(cb, "/v3/streams/" + (encodeURIComponent(id)) + "/contents", 'GET', input); + input = (function() { + switch (typeof options) { + case 'function': + cb = options; + return {}; + case 'string': + return { + continuation: options + }; + case 'object': + return options; + default: + return {}; + } + })(); + return this._requestURL(cb, "/v3/streams/" + (encodeURIComponent(id)) + "/contents", 'GET', input); }; Feedly.prototype.subscriptions = function(cb) { diff --git a/src/feedly.coffee b/src/feedly.coffee index 063b313..46c4c96 100644 --- a/src/feedly.coffee +++ b/src/feedly.coffee @@ -536,14 +536,22 @@ module.exports = class Feedly # Get the content of a stream # # @param id [string] the id of the stream - # @param continuation [string] a continuation id is used to page + # @param options [string|object] a continuation id is used to page + # or an object with stream request parameters # @param cb [function(error, Array(Page))] Optional callback # @return [promise(Array(Page))] - contents: (id, continuation, cb) -> - input = {} - if continuation? - input.continuation = continuation - @_request cb, "/v3/streams/#{encodeURIComponent(id)}/contents", 'GET', input + contents: (id, options, cb) -> + input = switch typeof(options) + when 'function' + cb = options + {} + when 'string' + continuation: options + when 'object' + options + else + {} + @_requestURL cb, "/v3/streams/#{encodeURIComponent(id)}/contents", 'GET', input # Get the user’s subscriptions # diff --git a/test/feedly.test.coffee b/test/feedly.test.coffee index a12c344..6c4556c 100644 --- a/test/feedly.test.coffee +++ b/test/feedly.test.coffee @@ -113,6 +113,10 @@ module.exports = test.ok Array.isArray(contents.items) test.ok contents.continuation f.contents FEED, contents.continuation + .then (contents) -> + test.ok contents + test.ok Array.isArray(contents.items) + f.contents FEED, {unreadOnly:true} .then (contents) -> test.ok contents f.markFeedRead FEED