Class: Ayadn::Endpoints
- Inherits:
-
Object
- Object
- Ayadn::Endpoints
- Defined in:
- lib/ayadn/endpoints.rb
Instance Attribute Summary collapse
-
#ayadn_callback_url ⇒ Object
Returns the value of attribute ayadn_callback_url.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#channels_url ⇒ Object
Returns the value of attribute channels_url.
-
#config_api_url ⇒ Object
Returns the value of attribute config_api_url.
-
#files_url ⇒ Object
Returns the value of attribute files_url.
-
#pm_url ⇒ Object
Returns the value of attribute pm_url.
-
#posts_url ⇒ Object
Returns the value of attribute posts_url.
-
#token_url ⇒ Object
Returns the value of attribute token_url.
-
#users_url ⇒ Object
Returns the value of attribute users_url.
Instance Method Summary collapse
- #authorize_url ⇒ Object
- #avatar ⇒ Object
- #block(username) ⇒ Object
- #blocked(options) ⇒ Object
- #channel(channel_id, options = {}) ⇒ Object
- #channels(options) ⇒ Object
- #checkins(options) ⇒ Object
- #conversations(options) ⇒ Object
- #convo(post_id, options) ⇒ Object
- #cover ⇒ Object
- #delete_message(channel_id, message_id) ⇒ Object
- #delete_post(post_id) ⇒ Object
- #file(file_id) ⇒ Object
- #files ⇒ Object
- #files_list(options) ⇒ Object
- #follow(username) ⇒ Object
- #followers(username, options) ⇒ Object
- #followings(username, options) ⇒ Object
- #global(options) ⇒ Object
- #hashtag(hashtag) ⇒ Object
-
#initialize ⇒ Endpoints
constructor
A new instance of Endpoints.
- #interactions ⇒ Object
- #mentions(username, options) ⇒ Object
- #messages(channel_id, options = {}) ⇒ Object
- #mute(username) ⇒ Object
- #muted(options) ⇒ Object
- #photos(options) ⇒ Object
- #posts(username, options) ⇒ Object
- #repost(post_id) ⇒ Object
- #search(words, options) ⇒ Object
- #search_annotations(anno, options) ⇒ Object
- #search_channels(words, options) ⇒ Object
- #search_messages(channel_id, words, options) ⇒ Object
- #search_users(words, options) ⇒ Object
- #single_post(post_id, options) ⇒ Object
- #star(post_id) ⇒ Object
- #token_info ⇒ Object
- #trending(options) ⇒ Object
- #unified(options) ⇒ Object
- #update_marker ⇒ Object
-
#user(username) ⇒ Object
accepts a string.
-
#users(usernames) ⇒ Object
accepts an array.
- #whatstarred(username, options) ⇒ Object
- #whoreposted(post_id) ⇒ Object
- #whostarred(post_id) ⇒ Object
Constructor Details
#initialize ⇒ Endpoints
Returns a new instance of Endpoints.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ayadn/endpoints.rb', line 7 def initialize @ayadn_callback_url = "http://aya.io/ayadn/auth.html" @base_url = "https://api.app.net/" @config_api_url = @base_url + "config" @posts_url = @base_url + "posts/" @users_url = @base_url + "users/" @files_url = @base_url + "files/" @token_url = @base_url + "token/" @channels_url = @base_url + "channels/" @pm_url = @channels_url + "pm/messages" end |
Instance Attribute Details
#ayadn_callback_url ⇒ Object
Returns the value of attribute ayadn_callback_url.
5 6 7 |
# File 'lib/ayadn/endpoints.rb', line 5 def ayadn_callback_url @ayadn_callback_url end |
#base_url ⇒ Object
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/ayadn/endpoints.rb', line 5 def base_url @base_url end |
#channels_url ⇒ Object
Returns the value of attribute channels_url.
5 6 7 |
# File 'lib/ayadn/endpoints.rb', line 5 def channels_url @channels_url end |
#config_api_url ⇒ Object
Returns the value of attribute config_api_url.
5 6 7 |
# File 'lib/ayadn/endpoints.rb', line 5 def config_api_url @config_api_url end |
#files_url ⇒ Object
Returns the value of attribute files_url.
5 6 7 |
# File 'lib/ayadn/endpoints.rb', line 5 def files_url @files_url end |
#pm_url ⇒ Object
Returns the value of attribute pm_url.
5 6 7 |
# File 'lib/ayadn/endpoints.rb', line 5 def pm_url @pm_url end |
#posts_url ⇒ Object
Returns the value of attribute posts_url.
5 6 7 |
# File 'lib/ayadn/endpoints.rb', line 5 def posts_url @posts_url end |
#token_url ⇒ Object
Returns the value of attribute token_url.
5 6 7 |
# File 'lib/ayadn/endpoints.rb', line 5 def token_url @token_url end |
#users_url ⇒ Object
Returns the value of attribute users_url.
5 6 7 |
# File 'lib/ayadn/endpoints.rb', line 5 def users_url @users_url end |
Instance Method Details
#authorize_url ⇒ Object
19 20 21 |
# File 'lib/ayadn/endpoints.rb', line 19 def "https://account.app.net/oauth/authenticate?client_id=#{Settings::AYADN_CLIENT_ID}&response_type=token&redirect_uri=#{@ayadn_callback_url}&scope=basic,stream,write_post,follow,public_messages,messages,files,update_profile&include_marker=1" end |
#avatar ⇒ Object
267 268 269 |
# File 'lib/ayadn/endpoints.rb', line 267 def avatar "#{@users_url}me/avatar" end |
#block(username) ⇒ Object
243 244 245 |
# File 'lib/ayadn/endpoints.rb', line 243 def block(username) "#{@users_url}#{username}/block?access_token=#{Settings.user_token}" end |
#blocked(options) ⇒ Object
157 158 159 |
# File 'lib/ayadn/endpoints.rb', line 157 def blocked() "#{@users_url}me/blocked/?access_token=#{Settings.user_token}&count=#{[:count]}&before_id=#{[:before_id]}" end |
#channel(channel_id, options = {}) ⇒ Object
259 260 261 |
# File 'lib/ayadn/endpoints.rb', line 259 def channel(channel_id, = {}) "#{@channels_url}?ids=#{channel_id.join(',')}&access_token=#{Settings.user_token}#{API.build_query()}&include_marker=1" end |
#channels(options) ⇒ Object
255 256 257 |
# File 'lib/ayadn/endpoints.rb', line 255 def channels() "#{@channels_url}?access_token=#{Settings.user_token}#{API.build_query()}" end |
#checkins(options) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/ayadn/endpoints.rb', line 44 def checkins() @options_list = if [:count] || [:since_id] API.build_query() else API.build_query({count: Settings.[:counts][:checkins]}) end "#{@posts_url}stream/explore/checkins?access_token=#{Settings.user_token}#{@options_list}" end |
#conversations(options) ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/ayadn/endpoints.rb', line 84 def conversations() @options_list = if [:count] || [:since_id] API.build_query() else API.build_query({count: Settings.[:counts][:conversations]}) end "#{@posts_url}stream/explore/conversations?access_token=#{Settings.user_token}#{@options_list}" end |
#convo(post_id, options) ⇒ Object
136 137 138 139 140 141 142 143 |
# File 'lib/ayadn/endpoints.rb', line 136 def convo(post_id, ) @options_list = if [:count] API.build_query() else API.build_query({count: Settings.[:counts][:convo]}) end "#{@posts_url}#{post_id}/replies/?access_token=#{Settings.user_token}#{@options_list}" end |
#cover ⇒ Object
271 272 273 |
# File 'lib/ayadn/endpoints.rb', line 271 def cover "#{@users_url}me/cover" end |
#delete_message(channel_id, message_id) ⇒ Object
231 232 233 |
# File 'lib/ayadn/endpoints.rb', line 231 def (channel_id, ) "#{@channels_url}/#{channel_id}/messages/#{}?access_token=#{Settings.user_token}" end |
#delete_post(post_id) ⇒ Object
227 228 229 |
# File 'lib/ayadn/endpoints.rb', line 227 def delete_post(post_id) "#{@posts_url}#{post_id}?access_token=#{Settings.user_token}" end |
#file(file_id) ⇒ Object
27 28 29 |
# File 'lib/ayadn/endpoints.rb', line 27 def file(file_id) "#{@files_url}#{file_id}?access_token=#{Settings.user_token}" end |
#files ⇒ Object
31 32 33 |
# File 'lib/ayadn/endpoints.rb', line 31 def files "#{@files_url}?access_token=#{Settings.user_token}" end |
#files_list(options) ⇒ Object
218 219 220 221 222 223 224 225 |
# File 'lib/ayadn/endpoints.rb', line 218 def files_list() @options_list = if [:count] API.build_query() else API.build_query({count: Settings.[:counts][:files]}) end "#{@users_url}me/files?access_token=#{Settings.user_token}#{@options_list}" end |
#follow(username) ⇒ Object
235 236 237 |
# File 'lib/ayadn/endpoints.rb', line 235 def follow(username) "#{@users_url}#{username}/follow?access_token=#{Settings.user_token}" end |
#followers(username, options) ⇒ Object
149 150 151 |
# File 'lib/ayadn/endpoints.rb', line 149 def followers(username, ) "#{@users_url}#{username}/followers/?access_token=#{Settings.user_token}&count=#{[:count]}&before_id=#{[:before_id]}" end |
#followings(username, options) ⇒ Object
145 146 147 |
# File 'lib/ayadn/endpoints.rb', line 145 def followings(username, ) "#{@users_url}#{username}/following/?access_token=#{Settings.user_token}&count=#{[:count]}&before_id=#{[:before_id]}" end |
#global(options) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ayadn/endpoints.rb', line 53 def global() @options_list = if [:count] || [:since_id] API.build_query() else API.build_query({count: Settings.[:counts][:global]}) end if Settings.global[:force] == true "#{@posts_url}stream/global?#{@options_list}" else "#{@posts_url}stream/global?access_token=#{Settings.user_token}#{@options_list}" end end |
#hashtag(hashtag) ⇒ Object
161 162 163 |
# File 'lib/ayadn/endpoints.rb', line 161 def hashtag(hashtag) "#{@posts_url}tag/#{hashtag}" end |
#interactions ⇒ Object
124 125 126 |
# File 'lib/ayadn/endpoints.rb', line 124 def interactions "#{@users_url}me/interactions?access_token=#{Settings.user_token}" end |
#mentions(username, options) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/ayadn/endpoints.rb', line 93 def mentions(username, ) @options_list = if [:count] API.build_query() else API.build_query({count: Settings.[:counts][:mentions]}) end "#{@users_url}#{username}/mentions/?access_token=#{Settings.user_token}#{@options_list}" end |
#messages(channel_id, options = {}) ⇒ Object
263 264 265 |
# File 'lib/ayadn/endpoints.rb', line 263 def (channel_id, = {}) "#{@channels_url}#{channel_id}/messages?access_token=#{Settings.user_token}#{API.build_query()}&include_machine=1&include_marker=1" end |
#mute(username) ⇒ Object
239 240 241 |
# File 'lib/ayadn/endpoints.rb', line 239 def mute(username) "#{@users_url}#{username}/mute?access_token=#{Settings.user_token}" end |
#muted(options) ⇒ Object
153 154 155 |
# File 'lib/ayadn/endpoints.rb', line 153 def muted() "#{@users_url}me/muted/?access_token=#{Settings.user_token}&count=#{[:count]}&before_id=#{[:before_id]}" end |
#photos(options) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/ayadn/endpoints.rb', line 75 def photos() @options_list = if [:count] || [:since_id] API.build_query() else API.build_query({count: Settings.[:counts][:photos]}) end "#{@posts_url}stream/explore/photos?access_token=#{Settings.user_token}#{@options_list}" end |
#posts(username, options) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/ayadn/endpoints.rb', line 102 def posts(username, ) @options_list = if [:count] API.build_query() else API.build_query({count: Settings.[:counts][:posts]}) end if Settings.global[:force] == true "#{@users_url}#{username}/posts/?#{@options_list}" else "#{@users_url}#{username}/posts/?access_token=#{Settings.user_token}#{@options_list}" end end |
#repost(post_id) ⇒ Object
247 248 249 |
# File 'lib/ayadn/endpoints.rb', line 247 def repost(post_id) "#{@posts_url}#{post_id}/repost?access_token=#{Settings.user_token}" end |
#search(words, options) ⇒ Object
165 166 167 168 169 170 171 172 |
# File 'lib/ayadn/endpoints.rb', line 165 def search(words, ) @options_list = if [:count] API.build_query() else API.build_query({count: Settings.[:counts][:search]}) end "#{@posts_url}search?text=#{words}&access_token=#{Settings.user_token}#{@options_list}" end |
#search_annotations(anno, options) ⇒ Object
183 184 185 186 187 188 189 190 |
# File 'lib/ayadn/endpoints.rb', line 183 def search_annotations anno, @options_list = if [:count] API.build_query() else API.build_query({count: Settings.[:counts][:search]}) end "#{@posts_url}search?annotation_types=#{anno}&access_token=#{Settings.user_token}#{@options_list}" end |
#search_channels(words, options) ⇒ Object
201 202 203 204 |
# File 'lib/ayadn/endpoints.rb', line 201 def search_channels words, @options_list = API.build_query({count: Settings.[:counts][:search]}) "#{@channels_url}search?q=#{words}&order=popularity&access_token=#{Settings.user_token}#{@options_list}" end |
#search_messages(channel_id, words, options) ⇒ Object
192 193 194 195 196 197 198 199 |
# File 'lib/ayadn/endpoints.rb', line 192 def channel_id, words, @options_list = if [:count] API.build_query() else API.build_query({count: Settings.[:counts][:search]}) end "#{@channels_url}messages/search?query=#{words}&channel_ids=#{channel_id}&access_token=#{Settings.user_token}#{@options_list}" end |
#search_users(words, options) ⇒ Object
174 175 176 177 178 179 180 181 |
# File 'lib/ayadn/endpoints.rb', line 174 def search_users words, @options_list = if [:count] API.build_query() else API.build_query({count: Settings.[:counts][:search]}) end "#{@users_url}search?q=#{words}&access_token=#{Settings.user_token}#{@options_list}" end |
#single_post(post_id, options) ⇒ Object
214 215 216 |
# File 'lib/ayadn/endpoints.rb', line 214 def single_post(post_id, ) "#{@posts_url}#{post_id}?access_token=#{Settings.user_token}#{API.build_query()}" end |
#star(post_id) ⇒ Object
251 252 253 |
# File 'lib/ayadn/endpoints.rb', line 251 def star(post_id) "#{@posts_url}#{post_id}/star?access_token=#{Settings.user_token}" end |
#token_info ⇒ Object
23 24 25 |
# File 'lib/ayadn/endpoints.rb', line 23 def token_info "#{@token_url}?access_token=#{Settings.user_token}" end |
#trending(options) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/ayadn/endpoints.rb', line 66 def trending() @options_list = if [:count] || [:since_id] API.build_query() else API.build_query({count: Settings.[:counts][:trending]}) end "#{@posts_url}stream/explore/trending?access_token=#{Settings.user_token}#{@options_list}" end |
#unified(options) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/ayadn/endpoints.rb', line 35 def unified() @options_list = if [:count] || [:since_id] API.build_query() else API.build_query({count: Settings.[:counts][:unified]}) end "#{@posts_url}stream/unified?access_token=#{Settings.user_token}#{@options_list}" end |
#update_marker ⇒ Object
275 276 277 |
# File 'lib/ayadn/endpoints.rb', line 275 def update_marker "#{@posts_url}marker?access_token=#{Settings.user_token}" end |
#user(username) ⇒ Object
accepts a string
206 207 208 |
# File 'lib/ayadn/endpoints.rb', line 206 def user(username) # accepts a string "#{@users_url}#{username}?access_token=#{Settings.user_token}&include_user_annotations=1" end |
#users(usernames) ⇒ Object
accepts an array
210 211 212 |
# File 'lib/ayadn/endpoints.rb', line 210 def users(usernames) # accepts an array "#{@users_url}?ids=#{usernames.join(',')}?access_token=#{Settings.user_token}&include_user_annotations=1" end |
#whatstarred(username, options) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/ayadn/endpoints.rb', line 115 def whatstarred(username, ) @options_list = if [:count] API.build_query() else API.build_query({count: Settings.[:counts][:default]}) end "#{@users_url}#{username}/stars/?access_token=#{Settings.user_token}#{@options_list}" end |
#whoreposted(post_id) ⇒ Object
128 129 130 |
# File 'lib/ayadn/endpoints.rb', line 128 def whoreposted(post_id) "#{@posts_url}#{post_id}/reposters/?access_token=#{Settings.user_token}" end |
#whostarred(post_id) ⇒ Object
132 133 134 |
# File 'lib/ayadn/endpoints.rb', line 132 def whostarred(post_id) "#{@posts_url}#{post_id}/stars/?access_token=#{Settings.user_token}" end |