class Ayadn::Endpoints
Constants
- CALLBACK_URL
Attributes
ayadn_callback_url[RW]
base_url[RW]
channels_url[RW]
config_api_url[RW]
files_url[RW]
pm_url[RW]
posts_url[RW]
token_url[RW]
users_url[RW]
Public Class Methods
new()
click to toggle source
# File lib/ayadn/endpoints.rb, line 9 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
Public Instance Methods
avatar()
click to toggle source
# File lib/ayadn/endpoints.rb, line 264 def avatar "#{@users_url}me/avatar" end
block(username)
click to toggle source
# File lib/ayadn/endpoints.rb, line 240 def block(username) "#{@users_url}#{username}/block?access_token=#{Settings.user_token}" end
blocked(options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 164 def blocked(options) "#{@users_url}me/blocked/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}" end
channel(channel_id, options = {})
click to toggle source
# File lib/ayadn/endpoints.rb, line 256 def channel(channel_id, options = {}) "#{@channels_url}?ids=#{channel_id.join(',')}&access_token=#{Settings.user_token}#{API.build_query(options)}&include_marker=1" end
channels(options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 252 def channels(options) "#{@channels_url}?access_token=#{Settings.user_token}#{API.build_query(options)}" end
checkins(options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 69 def checkins(options) make_options_list(options) do API.build_query({count: Settings.options.counts.checkins}) end "#{@posts_url}stream/explore/checkins?access_token=#{Settings.user_token}#{@options_list}" end
conversations(options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 101 def conversations(options) make_options_list(options) do API.build_query({count: Settings.options.counts.conversations}) end "#{@posts_url}stream/explore/conversations?access_token=#{Settings.user_token}#{@options_list}" end
convo(post_id, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 145 def convo(post_id, options) make_options_list_simple(options) do API.build_query({count: Settings.options.counts.convo}) end "#{@posts_url}#{post_id}/replies/?access_token=#{Settings.user_token}#{@options_list}" end
cover()
click to toggle source
# File lib/ayadn/endpoints.rb, line 268 def cover "#{@users_url}me/cover" end
delete_message(channel_id, message_id)
click to toggle source
# File lib/ayadn/endpoints.rb, line 228 def delete_message(channel_id, message_id) "#{@channels_url}/#{channel_id}/messages/#{message_id}?access_token=#{Settings.user_token}" end
delete_post(post_id)
click to toggle source
# File lib/ayadn/endpoints.rb, line 224 def delete_post(post_id) "#{@posts_url}#{post_id}?access_token=#{Settings.user_token}" end
file(file_id)
click to toggle source
# File lib/ayadn/endpoints.rb, line 34 def file(file_id) "#{@files_url}#{file_id}?access_token=#{Settings.user_token}" end
files()
click to toggle source
# File lib/ayadn/endpoints.rb, line 38 def files "#{@files_url}?access_token=#{Settings.user_token}" end
files_list(options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 217 def files_list(options) make_options_list_simple(options) do API.build_query({count: Settings.options.counts.files}) end "#{@users_url}me/files?access_token=#{Settings.user_token}#{@options_list}" end
follow(username)
click to toggle source
# File lib/ayadn/endpoints.rb, line 232 def follow(username) "#{@users_url}#{username}/follow?access_token=#{Settings.user_token}" end
followers(username, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 156 def followers(username, options) "#{@users_url}#{username}/followers/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}" end
followings(username, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 152 def followings(username, options) "#{@users_url}#{username}/following/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}" end
global(options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 76 def global(options) make_options_list(options) do API.build_query({count: Settings.options.counts.global}) end if Settings.global.force "#{@posts_url}stream/global?#{@options_list}" else "#{@posts_url}stream/global?access_token=#{Settings.user_token}#{@options_list}" end end
hashtag(hashtag)
click to toggle source
# File lib/ayadn/endpoints.rb, line 168 def hashtag(hashtag) "#{@posts_url}tag/#{hashtag}" end
interactions()
click to toggle source
# File lib/ayadn/endpoints.rb, line 133 def interactions "#{@users_url}me/interactions?access_token=#{Settings.user_token}" end
mentions(username, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 108 def mentions(username, options) make_options_list_simple(options) do API.build_query({count: Settings.options.counts.mentions}) end "#{@users_url}#{username}/mentions/?access_token=#{Settings.user_token}#{@options_list}" end
messages(channel_id, options = {})
click to toggle source
# File lib/ayadn/endpoints.rb, line 260 def messages(channel_id, options = {}) "#{@channels_url}#{channel_id}/messages?access_token=#{Settings.user_token}#{API.build_query(options)}&include_machine=1&include_marker=1" end
mute(username)
click to toggle source
# File lib/ayadn/endpoints.rb, line 236 def mute(username) "#{@users_url}#{username}/mute?access_token=#{Settings.user_token}" end
muted(options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 160 def muted(options) "#{@users_url}me/muted/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}" end
photos(options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 94 def photos(options) make_options_list(options) do API.build_query({count: Settings.options.counts.photos}) end "#{@posts_url}stream/explore/photos?access_token=#{Settings.user_token}#{@options_list}" end
posts(username, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 115 def posts(username, options) make_options_list_simple(options) do API.build_query({count: Settings.options.counts.posts}) end if Settings.global.force "#{@users_url}#{username}/posts/?#{@options_list}" else "#{@users_url}#{username}/posts/?access_token=#{Settings.user_token}#{@options_list}" end end
repost(post_id)
click to toggle source
# File lib/ayadn/endpoints.rb, line 244 def repost(post_id) "#{@posts_url}#{post_id}/repost?access_token=#{Settings.user_token}" end
search(words, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 172 def search(words, options) make_options_list_simple(options) do API.build_query({count: Settings.options.counts.search}) end "#{@posts_url}search?text=#{words}&access_token=#{Settings.user_token}#{@options_list}" end
search_annotations(anno, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 186 def search_annotations anno, options make_options_list_simple(options) do API.build_query({count: Settings.options.counts.search}) end "#{@posts_url}search?annotation_types=#{anno}&access_token=#{Settings.user_token}#{@options_list}" end
search_channels(words, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 200 def search_channels words, options @options_list = API.build_query({count: Settings.options.counts.search}) "#{@channels_url}search?q=#{words}&order=popularity&access_token=#{Settings.user_token}#{@options_list}" end
search_messages(channel_id, words, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 193 def search_messages channel_id, words, options make_options_list_simple(options) do API.build_query({count: Settings.options.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)
click to toggle source
# File lib/ayadn/endpoints.rb, line 179 def search_users words, options make_options_list_simple(options) do API.build_query({count: Settings.options.counts.search}) end "#{@users_url}search?q=#{words}&access_token=#{Settings.user_token}#{@options_list}" end
single_post(post_id, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 213 def single_post(post_id, options) "#{@posts_url}#{post_id}?access_token=#{Settings.user_token}#{API.build_query(options)}" end
star(post_id)
click to toggle source
# File lib/ayadn/endpoints.rb, line 248 def star(post_id) "#{@posts_url}#{post_id}/star?access_token=#{Settings.user_token}" end
token_info()
click to toggle source
# File lib/ayadn/endpoints.rb, line 30 def token_info "#{@token_url}?access_token=#{Settings.user_token}" end
trending(options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 87 def trending(options) make_options_list(options) do API.build_query({count: Settings.options.counts.trending}) end "#{@posts_url}stream/explore/trending?access_token=#{Settings.user_token}#{@options_list}" end
unified(options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 62 def unified(options) make_options_list(options) do API.build_query({count: Settings.options.counts.unified}) end "#{@posts_url}stream/unified?access_token=#{Settings.user_token}#{@options_list}" end
update_marker()
click to toggle source
# File lib/ayadn/endpoints.rb, line 272 def update_marker "#{@posts_url}marker?access_token=#{Settings.user_token}" end
user(username)
click to toggle source
# File lib/ayadn/endpoints.rb, line 205 def user(username) # accepts a string "#{@users_url}#{username}?access_token=#{Settings.user_token}&include_user_annotations=1" end
users(usernames)
click to toggle source
# File lib/ayadn/endpoints.rb, line 209 def users(usernames) # accepts an array "#{@users_url}?ids=#{usernames.join(',')}?access_token=#{Settings.user_token}&include_user_annotations=1" end
whatstarred(username, options)
click to toggle source
# File lib/ayadn/endpoints.rb, line 126 def whatstarred(username, options) make_options_list_simple(options) do API.build_query({count: Settings.options.counts.default}) end "#{@users_url}#{username}/stars/?access_token=#{Settings.user_token}#{@options_list}" end
whoreposted(post_id)
click to toggle source
# File lib/ayadn/endpoints.rb, line 137 def whoreposted(post_id) "#{@posts_url}#{post_id}/reposters/?access_token=#{Settings.user_token}" end
whostarred(post_id)
click to toggle source
# File lib/ayadn/endpoints.rb, line 141 def whostarred(post_id) "#{@posts_url}#{post_id}/stars/?access_token=#{Settings.user_token}" end
Private Instance Methods
make_options_list(options) { || ... }
click to toggle source
# File lib/ayadn/endpoints.rb, line 44 def make_options_list(options) @options_list = if options[:count] || options[:since_id] API.build_query(options) else yield end end
make_options_list_simple(options) { || ... }
click to toggle source
# File lib/ayadn/endpoints.rb, line 52 def make_options_list_simple(options) @options_list = if options[:count] API.build_query(options) else yield end end