Class: Twitter::REST::Client
- Includes:
- API
- Defined in:
- lib/twitter/rest/client.rb
Constant Summary collapse
Constants included from Users
Constants included from Utils
Utils::DEFAULT_CURSOR, Utils::URI_SUBSTRING
Constants included from Tweets
Tweets::MAX_TWEETS_PER_REQUEST
Constants included from Timelines
Timelines::DEFAULT_TWEETS_PER_REQUEST, Timelines::MAX_TWEETS_PER_REQUEST
Constants included from Search
Search::MAX_TWEETS_PER_REQUEST
Constants included from Lists
Lists::MAX_USERS_PER_REQUEST, Lists::URI_SUBSTRING
Instance Attribute Summary collapse
-
#bearer_token ⇒ Object
Returns the value of attribute bearer_token.
Attributes inherited from Client
#access_token, #access_token_secret, #consumer_key, #consumer_secret, #proxy, #user_agent
Instance Method Summary collapse
- #bearer_token? ⇒ Boolean
-
#connection ⇒ Faraday::Connection
Returns a Faraday::Connection object.
- #connection_options ⇒ Hash
- #connection_options=(connection_options) ⇒ Hash
- #credentials? ⇒ Boolean
-
#get(path, options = {}) ⇒ Object
Perform an HTTP GET request.
- #middleware ⇒ Faraday::RackBuilder
- #middleware=(middleware) ⇒ Faraday::RackBuilder
-
#post(path, options = {}) ⇒ Object
Perform an HTTP POST request.
Methods included from Users
#block, #block?, #blocked, #blocked_ids, #contributees, #contributors, #mute, #muted, #muted_ids, #profile_banner, #remove_profile_banner, #settings, #unblock, #unmute, #update_delivery_device, #update_profile, #update_profile_background_image, #update_profile_banner, #update_profile_colors, #update_profile_image, #user, #user?, #user_search, #users, #verify_credentials
Methods included from Utils
Methods included from Undocumented
#following_followers_of, #tweet_count
Methods included from Tweets
#destroy_status, #oembed, #oembeds, #retweet, #retweet!, #retweeters_ids, #retweeters_of, #retweets, #status, #statuses, #update, #update!, #update_with_media
Methods included from Trends
#trends, #trends_available, #trends_closest
Methods included from Timelines
#home_timeline, #mentions_timeline, #retweeted_by_me, #retweeted_by_user, #retweeted_to_me, #retweets_of_me, #user_timeline
Methods included from SuggestedUsers
Methods included from SpamReporting
Methods included from Search
Methods included from SavedSearches
#create_saved_search, #destroy_saved_search, #saved_search, #saved_searches
Methods included from PlacesAndGeo
#geo_search, #place, #reverse_geocode, #similar_places
Methods included from OAuth
#invalidate_token, #reverse_token, #token
Methods included from Media
Methods included from Lists
#add_list_member, #add_list_members, #create_list, #destroy_list, #list, #list_member?, #list_members, #list_subscribe, #list_subscriber?, #list_subscribers, #list_timeline, #list_unsubscribe, #list_update, #lists, #memberships, #owned_lists, #remove_list_member, #remove_list_members, #subscriptions
Methods included from Help
#configuration, #languages, #privacy, #tos
Methods included from FriendsAndFollowers
#follow, #follow!, #follower_ids, #followers, #friend_ids, #friends, #friendship, #friendship?, #friendship_update, #friendships, #friendships_incoming, #friendships_outgoing, #no_retweet_ids, #unfollow
Methods included from Favorites
#favorite, #favorite!, #favorites, #unfavorite
Methods included from DirectMessages
#create_direct_message, #destroy_direct_message, #direct_message, #direct_messages, #direct_messages_received, #direct_messages_sent
Methods inherited from Client
#credentials, #initialize, #user_token?
Constructor Details
This class inherits a constructor from Twitter::Client
Instance Attribute Details
#bearer_token ⇒ Object
Returns the value of attribute bearer_token.
18 19 20 |
# File 'lib/twitter/rest/client.rb', line 18 def bearer_token @bearer_token end |
Instance Method Details
#bearer_token? ⇒ Boolean
84 85 86 |
# File 'lib/twitter/rest/client.rb', line 84 def bearer_token? !!bearer_token end |
#connection ⇒ Faraday::Connection
Returns a Faraday::Connection object
96 97 98 |
# File 'lib/twitter/rest/client.rb', line 96 def connection @connection ||= Faraday.new(BASE_URL, ) end |
#connection_options ⇒ Hash
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/twitter/rest/client.rb', line 28 def @connection_options ||= { :builder => middleware, :headers => { :accept => 'application/json', :user_agent => user_agent, }, :request => { :open_timeout => 10, :timeout => 30, }, :proxy => proxy, } end |
#connection_options=(connection_options) ⇒ Hash
22 23 24 25 |
# File 'lib/twitter/rest/client.rb', line 22 def () warn "#{Kernel.caller.first}: [DEPRECATION] #{self.class.name}##{__method__} is deprecated and will be removed." @connection_options = end |
#credentials? ⇒ Boolean
89 90 91 |
# File 'lib/twitter/rest/client.rb', line 89 def credentials? super || bearer_token? end |
#get(path, options = {}) ⇒ Object
Perform an HTTP GET request
72 73 74 75 |
# File 'lib/twitter/rest/client.rb', line 72 def get(path, = {}) warn "#{Kernel.caller.first}: [DEPRECATION] #{self.class.name}##{__method__} is deprecated. Use Twitter::REST::Request#perform instead." perform_get(path, ) end |
#middleware ⇒ Faraday::RackBuilder
Faraday's middleware stack implementation is comparable to that of Rack middleware. The order of middleware is important: the first middleware on the list wraps all others, while the last middleware is the innermost one.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/twitter/rest/client.rb', line 54 def middleware @middleware ||= Faraday::RackBuilder.new do |faraday| # Convert file uploads to Faraday::UploadIO objects faraday.request :twitter_multipart_with_file # Checks for files in the payload, otherwise leaves everything untouched faraday.request :multipart # Encodes as "application/x-www-form-urlencoded" if not already encoded faraday.request :url_encoded # Handle error responses faraday.response :twitter_raise_error # Parse JSON response bodies faraday.response :twitter_parse_json # Set default HTTP adapter faraday.adapter :net_http end end |
#middleware=(middleware) ⇒ Faraday::RackBuilder
45 46 47 48 |
# File 'lib/twitter/rest/client.rb', line 45 def middleware=(middleware) warn "#{Kernel.caller.first}: [DEPRECATION] #{self.class.name}##{__method__} is deprecated and will be removed." @middleware = middleware end |
#post(path, options = {}) ⇒ Object
Perform an HTTP POST request
78 79 80 81 |
# File 'lib/twitter/rest/client.rb', line 78 def post(path, = {}) warn "#{Kernel.caller.first}: [DEPRECATION] #{self.class.name}##{__method__} is deprecated. Use Twitter::REST::Request#perform instead." perform_post(path, ) end |