lib/ayadn/endpoints.rb in ayadn-3.0 vs lib/ayadn/endpoints.rb in ayadn-4.0

- old
+ new

@@ -2,15 +2,11 @@ module Ayadn class Endpoints attr_accessor :ayadn_callback_url, :base_url, :config_api_url, :posts_url, :users_url, :files_url, :token_url, :channels_url, :pm_url - # Warning - # comment next line require_relative "ids" - # uncomment and insert your own URL - # CALLBACK_URL = "" def initialize @ayadn_callback_url = CALLBACK_URL api_file = Dir.home + "/ayadn/.api.yml" @base_url = if File.exist?(api_file) @@ -63,75 +59,75 @@ public def unified(options) make_options_list(options) do - API.build_query({count: Settings.options[:counts][:unified]}) + API.build_query({count: Settings.options.counts.unified}) end "#{@posts_url}stream/unified?access_token=#{Settings.user_token}#{@options_list}" end def checkins(options) make_options_list(options) do - API.build_query({count: Settings.options[:counts][:checkins]}) + API.build_query({count: Settings.options.counts.checkins}) end "#{@posts_url}stream/explore/checkins?access_token=#{Settings.user_token}#{@options_list}" end def global(options) make_options_list(options) do - API.build_query({count: Settings.options[:counts][:global]}) + API.build_query({count: Settings.options.counts.global}) end - if Settings.global[:force] == true + if Settings.global.force "#{@posts_url}stream/global?#{@options_list}" else "#{@posts_url}stream/global?access_token=#{Settings.user_token}#{@options_list}" end end def trending(options) make_options_list(options) do - API.build_query({count: Settings.options[:counts][:trending]}) + API.build_query({count: Settings.options.counts.trending}) end "#{@posts_url}stream/explore/trending?access_token=#{Settings.user_token}#{@options_list}" end def photos(options) make_options_list(options) do - API.build_query({count: Settings.options[:counts][:photos]}) + API.build_query({count: Settings.options.counts.photos}) end "#{@posts_url}stream/explore/photos?access_token=#{Settings.user_token}#{@options_list}" end def conversations(options) make_options_list(options) do - API.build_query({count: Settings.options[:counts][:conversations]}) + API.build_query({count: Settings.options.counts.conversations}) end "#{@posts_url}stream/explore/conversations?access_token=#{Settings.user_token}#{@options_list}" end def mentions(username, options) make_options_list_simple(options) do - API.build_query({count: Settings.options[:counts][:mentions]}) + API.build_query({count: Settings.options.counts.mentions}) end "#{@users_url}#{username}/mentions/?access_token=#{Settings.user_token}#{@options_list}" end def posts(username, options) make_options_list_simple(options) do - API.build_query({count: Settings.options[:counts][:posts]}) + API.build_query({count: Settings.options.counts.posts}) end - if Settings.global[:force] == true + if Settings.global.force "#{@users_url}#{username}/posts/?#{@options_list}" else "#{@users_url}#{username}/posts/?access_token=#{Settings.user_token}#{@options_list}" end end def whatstarred(username, options) make_options_list_simple(options) do - API.build_query({count: Settings.options[:counts][:default]}) + API.build_query({count: Settings.options.counts.default}) end "#{@users_url}#{username}/stars/?access_token=#{Settings.user_token}#{@options_list}" end def interactions @@ -146,11 +142,11 @@ "#{@posts_url}#{post_id}/stars/?access_token=#{Settings.user_token}" end def convo(post_id, options) make_options_list_simple(options) do - API.build_query({count: Settings.options[:counts][:convo]}) + API.build_query({count: Settings.options.counts.convo}) end "#{@posts_url}#{post_id}/replies/?access_token=#{Settings.user_token}#{@options_list}" end def followings(username, options) @@ -173,38 +169,38 @@ "#{@posts_url}tag/#{hashtag}" end def search(words, options) make_options_list_simple(options) do - API.build_query({count: Settings.options[:counts][:search]}) + API.build_query({count: Settings.options.counts.search}) end "#{@posts_url}search?text=#{words}&access_token=#{Settings.user_token}#{@options_list}" end def search_users words, options make_options_list_simple(options) do - API.build_query({count: Settings.options[:counts][:search]}) + API.build_query({count: Settings.options.counts.search}) end "#{@users_url}search?q=#{words}&access_token=#{Settings.user_token}#{@options_list}" end def search_annotations anno, options make_options_list_simple(options) do - API.build_query({count: Settings.options[:counts][:search]}) + API.build_query({count: Settings.options.counts.search}) end "#{@posts_url}search?annotation_types=#{anno}&access_token=#{Settings.user_token}#{@options_list}" end def search_messages channel_id, words, options make_options_list_simple(options) do - API.build_query({count: Settings.options[:counts][:search]}) + 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 def search_channels words, options - @options_list = API.build_query({count: Settings.options[:counts][:search]}) + @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 def user(username) # accepts a string "#{@users_url}#{username}?access_token=#{Settings.user_token}&include_user_annotations=1" @@ -218,10 +214,10 @@ "#{@posts_url}#{post_id}?access_token=#{Settings.user_token}#{API.build_query(options)}" end def files_list(options) make_options_list_simple(options) do - API.build_query({count: Settings.options[:counts][:files]}) + API.build_query({count: Settings.options.counts.files}) end "#{@users_url}me/files?access_token=#{Settings.user_token}#{@options_list}" end def delete_post(post_id)