Class: Ayadn::Endpoints
- Defined in:
- lib/ayadn/ids.rb,
lib/ayadn/endpoints.rb
Constant Summary collapse
- CALLBACK_URL =
"http://aya.io/ayadn/auth.html"
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
uncomment and insert your own URL CALLBACK_URL = “”.
- #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
uncomment and insert your own URL CALLBACK_URL = “”
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ayadn/endpoints.rb', line 13 def initialize @ayadn_callback_url = CALLBACK_URL api_file = Dir.home + "/ayadn/.api.yml" @base_url = if File.exist?(api_file) YAML.load(File.read(api_file))[:root] + "/" else "https://api.app.net/" end @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
30 31 32 |
# File 'lib/ayadn/endpoints.rb', line 30 def "https://account.app.net/oauth/authenticate?client_id=#{Settings::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
268 269 270 |
# File 'lib/ayadn/endpoints.rb', line 268 def avatar "#{@users_url}me/avatar" end |
#block(username) ⇒ Object
244 245 246 |
# File 'lib/ayadn/endpoints.rb', line 244 def block(username) "#{@users_url}#{username}/block?access_token=#{Settings.user_token}" end |
#blocked(options) ⇒ Object
168 169 170 |
# File 'lib/ayadn/endpoints.rb', line 168 def blocked() "#{@users_url}me/blocked/?access_token=#{Settings.user_token}&count=#{[:count]}&before_id=#{[:before_id]}" end |
#channel(channel_id, options = {}) ⇒ Object
260 261 262 |
# File 'lib/ayadn/endpoints.rb', line 260 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
256 257 258 |
# File 'lib/ayadn/endpoints.rb', line 256 def channels() "#{@channels_url}?access_token=#{Settings.user_token}#{API.build_query()}" end |
#checkins(options) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/ayadn/endpoints.rb', line 73 def checkins() () do API.build_query({count: Settings.[:counts][:checkins]}) end "#{@posts_url}stream/explore/checkins?access_token=#{Settings.user_token}#{@options_list}" end |
#conversations(options) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/ayadn/endpoints.rb', line 105 def conversations() () do 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
149 150 151 152 153 154 |
# File 'lib/ayadn/endpoints.rb', line 149 def convo(post_id, ) () do API.build_query({count: Settings.[:counts][:convo]}) end "#{@posts_url}#{post_id}/replies/?access_token=#{Settings.user_token}#{@options_list}" end |
#cover ⇒ Object
272 273 274 |
# File 'lib/ayadn/endpoints.rb', line 272 def cover "#{@users_url}me/cover" end |
#delete_message(channel_id, message_id) ⇒ Object
232 233 234 |
# File 'lib/ayadn/endpoints.rb', line 232 def (channel_id, ) "#{@channels_url}/#{channel_id}/messages/#{}?access_token=#{Settings.user_token}" end |
#delete_post(post_id) ⇒ Object
228 229 230 |
# File 'lib/ayadn/endpoints.rb', line 228 def delete_post(post_id) "#{@posts_url}#{post_id}?access_token=#{Settings.user_token}" end |
#file(file_id) ⇒ Object
38 39 40 |
# File 'lib/ayadn/endpoints.rb', line 38 def file(file_id) "#{@files_url}#{file_id}?access_token=#{Settings.user_token}" end |
#files ⇒ Object
42 43 44 |
# File 'lib/ayadn/endpoints.rb', line 42 def files "#{@files_url}?access_token=#{Settings.user_token}" end |
#files_list(options) ⇒ Object
221 222 223 224 225 226 |
# File 'lib/ayadn/endpoints.rb', line 221 def files_list() () do API.build_query({count: Settings.[:counts][:files]}) end "#{@users_url}me/files?access_token=#{Settings.user_token}#{@options_list}" end |
#follow(username) ⇒ Object
236 237 238 |
# File 'lib/ayadn/endpoints.rb', line 236 def follow(username) "#{@users_url}#{username}/follow?access_token=#{Settings.user_token}" end |
#followers(username, options) ⇒ Object
160 161 162 |
# File 'lib/ayadn/endpoints.rb', line 160 def followers(username, ) "#{@users_url}#{username}/followers/?access_token=#{Settings.user_token}&count=#{[:count]}&before_id=#{[:before_id]}" end |
#followings(username, options) ⇒ Object
156 157 158 |
# File 'lib/ayadn/endpoints.rb', line 156 def followings(username, ) "#{@users_url}#{username}/following/?access_token=#{Settings.user_token}&count=#{[:count]}&before_id=#{[:before_id]}" end |
#global(options) ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ayadn/endpoints.rb', line 80 def global() () do 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
172 173 174 |
# File 'lib/ayadn/endpoints.rb', line 172 def hashtag(hashtag) "#{@posts_url}tag/#{hashtag}" end |
#interactions ⇒ Object
137 138 139 |
# File 'lib/ayadn/endpoints.rb', line 137 def interactions "#{@users_url}me/interactions?access_token=#{Settings.user_token}" end |
#mentions(username, options) ⇒ Object
112 113 114 115 116 117 |
# File 'lib/ayadn/endpoints.rb', line 112 def mentions(username, ) () do 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
264 265 266 |
# File 'lib/ayadn/endpoints.rb', line 264 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
240 241 242 |
# File 'lib/ayadn/endpoints.rb', line 240 def mute(username) "#{@users_url}#{username}/mute?access_token=#{Settings.user_token}" end |
#muted(options) ⇒ Object
164 165 166 |
# File 'lib/ayadn/endpoints.rb', line 164 def muted() "#{@users_url}me/muted/?access_token=#{Settings.user_token}&count=#{[:count]}&before_id=#{[:before_id]}" end |
#photos(options) ⇒ Object
98 99 100 101 102 103 |
# File 'lib/ayadn/endpoints.rb', line 98 def photos() () do 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
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/ayadn/endpoints.rb', line 119 def posts(username, ) () do 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
248 249 250 |
# File 'lib/ayadn/endpoints.rb', line 248 def repost(post_id) "#{@posts_url}#{post_id}/repost?access_token=#{Settings.user_token}" end |
#search(words, options) ⇒ Object
176 177 178 179 180 181 |
# File 'lib/ayadn/endpoints.rb', line 176 def search(words, ) () do 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
190 191 192 193 194 195 |
# File 'lib/ayadn/endpoints.rb', line 190 def search_annotations anno, () do 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
204 205 206 207 |
# File 'lib/ayadn/endpoints.rb', line 204 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
197 198 199 200 201 202 |
# File 'lib/ayadn/endpoints.rb', line 197 def channel_id, words, () do 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
183 184 185 186 187 188 |
# File 'lib/ayadn/endpoints.rb', line 183 def search_users words, () do 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
217 218 219 |
# File 'lib/ayadn/endpoints.rb', line 217 def single_post(post_id, ) "#{@posts_url}#{post_id}?access_token=#{Settings.user_token}#{API.build_query()}" end |
#star(post_id) ⇒ Object
252 253 254 |
# File 'lib/ayadn/endpoints.rb', line 252 def star(post_id) "#{@posts_url}#{post_id}/star?access_token=#{Settings.user_token}" end |
#token_info ⇒ Object
34 35 36 |
# File 'lib/ayadn/endpoints.rb', line 34 def token_info "#{@token_url}?access_token=#{Settings.user_token}" end |
#trending(options) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/ayadn/endpoints.rb', line 91 def trending() () do API.build_query({count: Settings.[:counts][:trending]}) end "#{@posts_url}stream/explore/trending?access_token=#{Settings.user_token}#{@options_list}" end |
#unified(options) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/ayadn/endpoints.rb', line 66 def unified() () do API.build_query({count: Settings.[:counts][:unified]}) end "#{@posts_url}stream/unified?access_token=#{Settings.user_token}#{@options_list}" end |
#update_marker ⇒ Object
276 277 278 |
# File 'lib/ayadn/endpoints.rb', line 276 def update_marker "#{@posts_url}marker?access_token=#{Settings.user_token}" end |
#user(username) ⇒ Object
accepts a string
209 210 211 |
# File 'lib/ayadn/endpoints.rb', line 209 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
213 214 215 |
# File 'lib/ayadn/endpoints.rb', line 213 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
130 131 132 133 134 135 |
# File 'lib/ayadn/endpoints.rb', line 130 def whatstarred(username, ) () do API.build_query({count: Settings.[:counts][:default]}) end "#{@users_url}#{username}/stars/?access_token=#{Settings.user_token}#{@options_list}" end |
#whoreposted(post_id) ⇒ Object
141 142 143 |
# File 'lib/ayadn/endpoints.rb', line 141 def whoreposted(post_id) "#{@posts_url}#{post_id}/reposters/?access_token=#{Settings.user_token}" end |
#whostarred(post_id) ⇒ Object
145 146 147 |
# File 'lib/ayadn/endpoints.rb', line 145 def whostarred(post_id) "#{@posts_url}#{post_id}/stars/?access_token=#{Settings.user_token}" end |