Class: InoreaderApi::Api
- Inherits:
-
Object
- Object
- InoreaderApi::Api
- Defined in:
- lib/inoreader/api/app.rb
Instance Method Summary collapse
-
#add_folder_subscription(s, a) ⇒ Object
add folder to subscription.
-
#add_subscription(url) ⇒ Object
add Subscription.
-
#add_tag(items, add_tag = nil) ⇒ Object
add tag.
-
#auth_token ⇒ Object
return to auth token.
-
#disable_tag(tag_name) ⇒ Object
delete(disable) tag.
-
#edit_subscription(ac, s, t = nil, a = nil, r = nil) ⇒ Object
edit subscription.
-
#import ⇒ Object
OPML Import.
-
#initialize(options = {}) ⇒ String
constructor
set auth toke or username/password.
-
#item_ids(feed = '', params = {}) ⇒ Object
get user item ids.
-
#items(feed = '', params = {}) ⇒ Object
get user items.
-
#mark_all_as_read(ts, s) ⇒ Object
mark all as read.
-
#preferences_list ⇒ Object
preference list:current subscriptions sorting.
-
#remove_folder_subscription(s, r) ⇒ Object
remove folder to subscription.
-
#remove_tag(items, remove_tag) ⇒ Object
remove tag.
-
#rename_subscription(s, t) ⇒ Object
rename subscription title.
-
#rename_tag(source, dest) ⇒ Object
rename tag.
- #set_stream_preferences(s, k, v) ⇒ Object
-
#set_subscription_ordering(s, v) ⇒ Object
Set stream preferences.
-
#stream(path, feed = '', params = {}) ⇒ Object
stream output format : json only.
-
#stream_preferences_list ⇒ Object
Stream preferences list.
-
#subscribe(s, a) ⇒ Object
subscribe (=add Subscription).
-
#token ⇒ String
get token.
-
#unread_counters ⇒ Object
get unread counters.
-
#unsubscribe(s) ⇒ Object
unsubscribe.
-
#user_info ⇒ String
get user info.
-
#user_subscription ⇒ Object
get user subscriptions.
-
#user_tags_folders ⇒ Object
get user tags/folders.
Constructor Details
#initialize(options = {}) ⇒ String
set auth toke or username/password
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/inoreader/api/app.rb', line 13 def initialize(={}) # set default = { :return_httparty_response => false }.merge() @auth_token = .delete(:auth_token) if !@auth_token && .has_key?(:username) && .has_key?(:password) username = .delete(:username) password = .delete(:password) res = login(username, password) @auth_token = res end InoreaderApi::Helper.return_httparty_response = [:return_httparty_response] end |
Instance Method Details
#add_folder_subscription(s, a) ⇒ Object
add folder to subscription
160 161 162 |
# File 'lib/inoreader/api/app.rb', line 160 def add_folder_subscription(s, a) edit_subscription :edit, s, nil, a end |
#add_subscription(url) ⇒ Object
add Subscription
132 133 134 |
# File 'lib/inoreader/api/app.rb', line 132 def add_subscription(url) Helper.request '/reader/api/0/subscription/quickadd', {:query => {:T => @auth_token, quickadd: url}}, :post end |
#add_tag(items, add_tag = nil) ⇒ Object
add tag
112 113 114 |
# File 'lib/inoreader/api/app.rb', line 112 def add_tag(items, add_tag=nil) Helper.request '/reader/api/0/edit-tag', {:query => {:T => @auth_token, :i => items, :a => add_tag}}, :post end |
#auth_token ⇒ Object
return to auth token
30 31 32 |
# File 'lib/inoreader/api/app.rb', line 30 def auth_token @auth_token end |
#disable_tag(tag_name) ⇒ Object
delete(disable) tag
105 106 107 |
# File 'lib/inoreader/api/app.rb', line 105 def disable_tag(tag_name) Helper.request '/reader/api/0/disable-tag', {:query => {:T => @auth_token, s: tag_name}}, :post end |
#edit_subscription(ac, s, t = nil, a = nil, r = nil) ⇒ Object
edit subscription
142 143 144 145 146 147 148 |
# File 'lib/inoreader/api/app.rb', line 142 def edit_subscription(ac, s, t=nil, a=nil, r=nil) query = {:T => @auth_token, :ac => ac, :s => s} query[:t] = t unless t.nil? query[:a] = a unless a.nil? query[:r] = r unless r.nil? Helper.request '/reader/api/0/subscription/edit', {:query => query}, :post end |
#import ⇒ Object
OPML Import
47 48 49 |
# File 'lib/inoreader/api/app.rb', line 47 def import # todo end |
#item_ids(feed = '', params = {}) ⇒ Object
get user item ids
91 92 93 |
# File 'lib/inoreader/api/app.rb', line 91 def item_ids(feed='', params={}) stream '/reader/api/0/stream/items/ids', feed, params end |
#items(feed = '', params = {}) ⇒ Object
get user items
85 86 87 |
# File 'lib/inoreader/api/app.rb', line 85 def items(feed='', params={}) stream '/reader/atom', feed, params end |
#mark_all_as_read(ts, s) ⇒ Object
mark all as read. mark as read, older than ts.
126 127 128 |
# File 'lib/inoreader/api/app.rb', line 126 def mark_all_as_read(ts, s) Helper.request '/reader/api/0/mark-all-as-read', {:query => {:T => @auth_token, :ts => ts, :s => s}}, :post end |
#preferences_list ⇒ Object
preference list:current subscriptions sorting.
185 186 187 |
# File 'lib/inoreader/api/app.rb', line 185 def preferences_list Helper.request '/reader/api/0/preference/list', {:query => {:T => @auth_token}} end |
#remove_folder_subscription(s, r) ⇒ Object
remove folder to subscription
167 168 169 |
# File 'lib/inoreader/api/app.rb', line 167 def remove_folder_subscription(s, r) edit_subscription :edit, s, nil, nil, r end |
#remove_tag(items, remove_tag) ⇒ Object
remove tag
119 120 121 |
# File 'lib/inoreader/api/app.rb', line 119 def remove_tag(items, remove_tag) Helper.request '/reader/api/0/edit-tag', {:query => {:T => @auth_token, :i => items, :r => remove_tag}}, :post end |
#rename_subscription(s, t) ⇒ Object
rename subscription title
153 154 155 |
# File 'lib/inoreader/api/app.rb', line 153 def rename_subscription(s, t) edit_subscription :edit, s, t end |
#rename_tag(source, dest) ⇒ Object
rename tag
100 101 102 |
# File 'lib/inoreader/api/app.rb', line 100 def rename_tag(source, dest) Helper.request '/reader/api/0/rename-tag', {:query => {:T => @auth_token, s: source, dest: dest}}, :post end |
#set_stream_preferences(s, k, v) ⇒ Object
197 198 199 200 |
# File 'lib/inoreader/api/app.rb', line 197 def set_stream_preferences(s, k, v) query = {:query => {:T => @auth_token, :s => s, :k => k, :v => v}} Helper.request '/reader/api/0/preference/stream/set', query, :post end |
#set_subscription_ordering(s, v) ⇒ Object
Set stream preferences. now is “subscription-ordering” only :P
205 206 207 |
# File 'lib/inoreader/api/app.rb', line 205 def set_subscription_ordering(s, v) set_stream_preferences(s, 'subscription-ordering', v) end |
#stream(path, feed = '', params = {}) ⇒ Object
stream
output format : json only
77 78 79 80 81 |
# File 'lib/inoreader/api/app.rb', line 77 def stream(path, feed='', params={}) query = {:query => params.merge!(:T => @auth_token, :output => 'json')} feed_name = feed.empty? ? '' : ('/' + feed) Helper.request "#{path}#{feed_name}", query end |
#stream_preferences_list ⇒ Object
Stream preferences list
190 191 192 |
# File 'lib/inoreader/api/app.rb', line 190 def stream_preferences_list Helper.request '/reader/api/0/preference/stream/list', {:query => {:T => @auth_token}} end |
#subscribe(s, a) ⇒ Object
subscribe (=add Subscription)
180 181 182 |
# File 'lib/inoreader/api/app.rb', line 180 def subscribe(s, a) edit_subscription :subscribe, s, nil, a end |
#token ⇒ String
get token
42 43 44 |
# File 'lib/inoreader/api/app.rb', line 42 def token Helper.request '/reader/api/0/token', {:query => {:T => @auth_token}} end |
#unread_counters ⇒ Object
get unread counters
52 53 54 |
# File 'lib/inoreader/api/app.rb', line 52 def unread_counters Helper.request '/reader/api/0/unread-count?output=json', {:query => {:T => @auth_token}} end |
#unsubscribe(s) ⇒ Object
unsubscribe
173 174 175 |
# File 'lib/inoreader/api/app.rb', line 173 def unsubscribe(s) edit_subscription :unsubscribe, s end |
#user_info ⇒ String
get user info
36 37 38 |
# File 'lib/inoreader/api/app.rb', line 36 def user_info Helper.request '/reader/api/0/user-info', {:query => {:T => @auth_token}} end |