Class/Module Index [+]

Quicksearch

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]
connection_options[W]
middleware[W]

Public Instance Methods

bearer_token?() click to toggle source

@return [Boolean]

# File lib/twitter/rest/client.rb, line 112
def bearer_token?
  !!bearer_token
end
connection_options() click to toggle source
# File lib/twitter/rest/client.rb, line 55
def connection_options
  @connection_options ||= {
    :builder => middleware,
    :headers => {
      :accept => 'application/json',
      :user_agent => user_agent,
    },
    :request => {
      :open_timeout => 5,
      :timeout => 10,
    },
  }
end
credentials?() click to toggle source

@return [Boolean]

# File lib/twitter/rest/client.rb, line 117
def credentials?
  super || bearer_token?
end
delete(path, params = {}) click to toggle source

Perform an HTTP DELETE request

# File lib/twitter/rest/client.rb, line 91
def delete(path, params = {})
  request(:delete, path, params)
end
get(path, params = {}) click to toggle source

Perform an HTTP GET request

# File lib/twitter/rest/client.rb, line 96
def get(path, params = {})
  request(:get, path, params)
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::Builder]

# File lib/twitter/rest/client.rb, line 73
def middleware
  @middleware ||= Faraday::Builder.new do |builder|
    # Convert file uploads to Faraday::UploadIO objects
    builder.use Twitter::REST::Request::MultipartWithFile
    # Checks for files in the payload
    builder.use Faraday::Request::Multipart
    # Convert request params to "www-form-urlencoded"
    builder.use Faraday::Request::UrlEncoded
    # Handle error responses
    builder.use Twitter::REST::Response::RaiseError
    # Parse JSON response bodies
    builder.use Twitter::REST::Response::ParseJson
    # Set Faraday's HTTP adapter
    builder.adapter Faraday.default_adapter
  end
end
post(path, params = {}) click to toggle source

Perform an HTTP POST request

# File lib/twitter/rest/client.rb, line 101
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 = {}) click to toggle source

Perform an HTTP PUT request

# File lib/twitter/rest/client.rb, line 107
def put(path, params = {})
  request(:put, path, params)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.