Class: Twitter::Client

Overview

Note:

All methods have been separated into modules and follow the same grouping used in the Twitter API Documentation.

Wrapper for the Twitter REST API

Constant Summary

Constants included from API::Users

API::Users::MAX_USERS_PER_REQUEST

Constants included from API::Utils

API::Utils::DEFAULT_CURSOR

Constants included from API::Timelines

API::Timelines::DEFAULT_TWEETS_PER_REQUEST, API::Timelines::MAX_TWEETS_PER_REQUEST

Constants included from API::Lists

API::Lists::MAX_USERS_PER_REQUEST

Instance Attribute Summary

Attributes included from Configurable

#connection_options, #consumer_key, #consumer_secret, #endpoint, #identity_map, #middleware, #oauth_token, #oauth_token_secret

Instance Method Summary collapse

Methods included from Configurable

#configure, #credentials?, keys, #reset!

Methods included from API::Users

#block, #block?, #blocked_ids, #blocking, #contributees, #contributors, #profile_banner, #remove_profile_banner, #settings, #unblock, #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 API::Undocumented

#activity_about_me, #activity_by_friends, #following_followers_of, #status_activity, #statuses_activity

Methods included from API::Tweets

#oembed, #oembeds, #retweet, #retweet!, #retweeters_of, #retweets, #status, #status_destroy, #statuses, #update, #update_with_media

Methods included from API::Trends

#trends, #trends_available, #trends_closest

Methods included from API::Timelines

#home_timeline, #mentions_timeline, #retweeted_by_me, #retweeted_by_user, #retweeted_to_me, #retweets_of_me, #user_timeline

Methods included from API::SuggestedUsers

#suggest_users, #suggestions

Methods included from API::SpamReporting

#report_spam

Methods included from API::Search

#search

Methods included from API::SavedSearches

#saved_search, #saved_search_create, #saved_search_destroy, #saved_searches

Methods included from API::PlacesAndGeo

#geo_search, #place, #place_create, #reverse_geocode, #similar_places

Methods included from API::Lists

#list, #list_add_member, #list_add_members, #list_create, #list_destroy, #list_member?, #list_members, #list_remove_member, #list_remove_members, #list_subscribe, #list_subscriber?, #list_subscribers, #list_timeline, #list_unsubscribe, #list_update, #lists, #memberships, #subscriptions

Methods included from API::Help

#configuration, #languages, #privacy, #tos

Methods included from API::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 API::Favorites

#favorite, #favorite!, #favorites, #unfavorite

Methods included from API::DirectMessages

#direct_message, #direct_message_create, #direct_message_destroy, #direct_messages, #direct_messages_received, #direct_messages_sent

Constructor Details

#initialize(options = {}) ⇒ Twitter::Client

Initializes a new Client object

Parameters:

  • options (Hash) (defaults to: {})


51
52
53
54
55
# File 'lib/twitter/client.rb', line 51

def initialize(options={})
  Twitter::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", options[key] || Twitter.instance_variable_get(:"@#{key}"))
  end
end

Instance Method Details

#delete(path, params = {}) ⇒ Object

Perform an HTTP DELETE request



58
59
60
# File 'lib/twitter/client.rb', line 58

def delete(path, params={})
  request(:delete, path, params)
end

#get(path, params = {}) ⇒ Object

Perform an HTTP GET request



63
64
65
# File 'lib/twitter/client.rb', line 63

def get(path, params={})
  request(:get, path, params)
end

#post(path, params = {}) ⇒ Object

Perform an HTTP POST request



68
69
70
71
# File 'lib/twitter/client.rb', line 68

def post(path, params={})
  signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params
  request(:post, path, params, signature_params)
end

#put(path, params = {}) ⇒ Object

Perform an HTTP PUT request



74
75
76
# File 'lib/twitter/client.rb', line 74

def put(path, params={})
  request(:put, path, params)
end