Included Modules

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
URL_PREFIX

Attributes

bearer_token[RW]

Public Instance Methods

bearer_token?() click to toggle source

@return [Boolean]

# File lib/twitter/rest/client.rb, line 89
def bearer_token?
  !!bearer_token
end
connection_options() click to toggle source

@return [Hash]

# File lib/twitter/rest/client.rb, line 33
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 27
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 94
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 77
def get(path, params = {})
  headers = request_headers(:get, URL_PREFIX + 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 59
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 50
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 83
def post(path, params = {})
  headers = params.values.any? { |value| value.respond_to?(:to_io) } ? request_headers(:post, URL_PREFIX + path, params, {}) : request_headers(:post, URL_PREFIX + path, params)
  request(:post, path, params, headers)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.