Class: Twitter::Client

Inherits:
Object
  • Object
show all
Includes:
API::DirectMessages, API::Favorites, API::FriendsAndFollowers, API::Help, API::Lists, API::OAuth, API::PlacesAndGeo, API::SavedSearches, API::Search, API::SpamReporting, API::SuggestedUsers, API::Timelines, API::Trends, API::Tweets, API::Undocumented, API::Users, Configurable
Defined in:
lib/twitter/client.rb

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

See Also:

Constant Summary

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

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

Instance Method Summary (collapse)

Methods included from Configurable

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

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

#following_followers_of, #status_activity, #statuses_activity, #tweet_count

Methods included from API::Tweets

#oembed, #oembeds, #retweet, #retweet!, #retweeters_ids, #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::OAuth

#invalidate_token, #token

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, #lists_owned, #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

- (Twitter::Client) initialize(options = {})

Initializes a new Client object

Parameters:

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


53
54
55
56
57
# File 'lib/twitter/client.rb', line 53

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

- (Object) delete(path, params = {})

Perform an HTTP DELETE request



60
61
62
# File 'lib/twitter/client.rb', line 60

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

- (Object) get(path, params = {})

Perform an HTTP GET request



65
66
67
# File 'lib/twitter/client.rb', line 65

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

- (Object) post(path, params = {})

Perform an HTTP POST request



70
71
72
73
# File 'lib/twitter/client.rb', line 70

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

- (Object) put(path, params = {})

Perform an HTTP PUT request



76
77
78
# File 'lib/twitter/client.rb', line 76

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