### Home Classes Methods

### In Files

- lib/twitter/rest/client.rb

### Parent

Twitter::Client

### Methods

- #bearer_token?
- #connection_options
- #connection_options=
- #credentials?
- #get
- #middleware
- #middleware=
- #post

### Included Modules

- Twitter::REST::API

### Class/Module Index

Quicksearch

- Twitter
- Twitter::Arguments
- Twitter::Base
- Twitter::BasicUser
- Twitter::Client
- Twitter::Configuration
- Twitter::Creatable
- Twitter::Cursor
- Twitter::DirectMessage
- Twitter::Entities
- Twitter::Entity
- Twitter::Entity::Hashtag
- Twitter::Entity::Symbol
- Twitter::Entity::URI
- Twitter::Entity::URL
- Twitter::Entity::UserMention
- Twitter::Enumerable
- Twitter::Error
- Twitter::Error::AlreadyFavorited
- Twitter::Error::AlreadyRetweeted
- Twitter::Error::BadGateway
- Twitter::Error::BadRequest
- Twitter::Error::ClientError
- Twitter::Error::Code
- Twitter::Error::ConfigurationError
- Twitter::Error::DuplicateStatus
- Twitter::Error::Forbidden
- Twitter::Error::GatewayTimeout
- Twitter::Error::InternalServerError
- Twitter::Error::NotAcceptable
- Twitter::Error::NotFound
- Twitter::Error::RequestTimeout
- Twitter::Error::ServerError
- Twitter::Error::ServiceUnavailable
- Twitter::Error::TooManyRequests
- Twitter::Error::UnacceptableIO
- Twitter::Error::Unauthorized
- Twitter::Error::UnprocessableEntity
- Twitter::Factory
- Twitter::Geo
- Twitter::Geo::Point
- Twitter::Geo::Polygon
- Twitter::GeoFactory
- Twitter::GeoResults
- Twitter::Identity
- Twitter::Language
- Twitter::List
- Twitter::Media
- Twitter::Media::Photo
- Twitter::MediaFactory
- Twitter::Metadata
- Twitter::OEmbed
- Twitter::Place
- Twitter::Profile
- Twitter::ProfileBanner
- Twitter::REST
- Twitter::REST::API
- Twitter::REST::Client
- Twitter::REST::DirectMessages
- Twitter::REST::Favorites
- Twitter::REST::FriendsAndFollowers
- Twitter::REST::Help
- Twitter::REST::Lists
- Twitter::REST::OAuth
- Twitter::REST::PlacesAndGeo
- Twitter::REST::Request
- Twitter::REST::Request::MultipartWithFile
- Twitter::REST::Response
- Twitter::REST::Response::ParseErrorJson
- Twitter::REST::Response::ParseJson
- Twitter::REST::Response::RaiseError
- Twitter::REST::SavedSearches
- Twitter::REST::Search
- Twitter::REST::SpamReporting
- Twitter::REST::SuggestedUsers
- Twitter::REST::Timelines
- Twitter::REST::Trends
- Twitter::REST::Tweets
- Twitter::REST::Undocumented
- Twitter::REST::Users
- Twitter::REST::Utils
- Twitter::RateLimit
- Twitter::Relationship
- Twitter::Request
- Twitter::SavedSearch
- Twitter::SearchResults
- Twitter::Settings
- Twitter::Size
- Twitter::SourceUser
- Twitter::Streaming
- Twitter::Streaming::Client
- Twitter::Streaming::Connection
- Twitter::Streaming::DeletedTweet
- Twitter::Streaming::Event
- Twitter::Streaming::FriendList
- Twitter::Streaming::MessageParser
- Twitter::Streaming::Response
- Twitter::Streaming::StallWarning
- Twitter::Suggestion
- Twitter::TargetUser
- Twitter::Token
- Twitter::Trend
- Twitter::TrendResults
- Twitter::Tweet
- Twitter::User
- Twitter::Utils
- Twitter::Utils::ClassMethods
- Twitter::Version

No matching classes.

# Twitter::REST::Client

Wrapper for the Twitter REST API

@note All methods have been separated into modules and follow the same grouping used in {dev.twitter.com/doc the Twitter API Documentation}. @see dev.twitter.com/pages/every_developer

### Constants

ENDPOINT

### Attributes

bearer_token[RW]

### Public Instance Methods

bearer_token?() click to toggle source

@return [Boolean]

    # File lib/twitter/rest/client.rb, line 88
    def bearer_token?
      !!bearer_token
    end

connection_options() click to toggle source

@return [Hash]

    # File lib/twitter/rest/client.rb, line 32
    def connection_options
      @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) click to toggle source

@param connection_options [Hash] @return [Hash]

    # File lib/twitter/rest/client.rb, line 26
    def connection_options=(connection_options)
      warn "#{Kernel.caller.first}: [DEPRECATION] Twitter::REST::Client#connection_options= is deprecated and will be removed in version 6.0.0."
      @connection_options = connection_options
    end

credentials?() click to toggle source

@return [Boolean]

    # File lib/twitter/rest/client.rb, line 93
    def credentials?
      super || bearer_token?
    end

get(path, params = {}) click to toggle source

Perform an HTTP GET request

    # File lib/twitter/rest/client.rb, line 76
    def get(path, params = {})
      headers = request_headers(:get, path, params)
      request(:get, path, params, headers)
    end

middleware() click to toggle source

@note 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. @see github.com/technoweenie/faraday#advanced-middleware-usage @see mislav.uniqpath.com/2011/07/faraday-advanced-http/ @return [Faraday::RackBuilder]

    # File lib/twitter/rest/client.rb, line 58
    def middleware
      @middleware ||= Faraday::RackBuilder.new do |faraday|
        # Convert file uploads to Faraday::UploadIO objects
        faraday.request :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 :raise_error
        # Parse JSON response bodies
        faraday.response :parse_json
        # Set default HTTP adapter
        faraday.adapter :net_http
      end
    end

middleware=(middleware) click to toggle source

@params middleware [Faraday::RackBuilder] @return [Faraday::RackBuilder]

    # File lib/twitter/rest/client.rb, line 49
    def middleware=(middleware)
      warn "#{Kernel.caller.first}: [DEPRECATION] Twitter::REST::Client#middleware= is deprecated and will be removed in version 6.0.0."
      @middleware = middleware
    end

post(path, params = {}) click to toggle source

Perform an HTTP POST request

    # File lib/twitter/rest/client.rb, line 82
    def post(path, params = {})
      headers = params.values.any? { |value| value.respond_to?(:to_io) } ? request_headers(:post, path, params, {}) : request_headers(:post, path, params)
      request(:post, path, params, headers)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.