Class: Twitter::REST::Request
- Inherits:
-
Object
- Object
- Twitter::REST::Request
- Defined in:
- lib/twitter/rest/request.rb,
lib/twitter/rest/request/multipart_with_file.rb
Defined Under Namespace
Classes: MultipartWithFile
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
-
#rate_limit ⇒ Object
Returns the value of attribute rate_limit.
-
#request_method ⇒ Object
(also: #verb)
Returns the value of attribute request_method.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #initialize(client, request_method, path, options = {}) ⇒ Twitter::REST::Request constructor
- #perform ⇒ Array, Hash
Constructor Details
#initialize(client, request_method, path, options = {}) ⇒ Twitter::REST::Request
21 22 23 24 25 26 27 |
# File 'lib/twitter/rest/request.rb', line 21 def initialize(client, request_method, path, = {}) @client = client @request_method = request_method.to_sym @path = path @uri = Addressable::URI.parse(client.connection.url_prefix + path) @options = end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
12 13 14 |
# File 'lib/twitter/rest/request.rb', line 12 def client @client end |
#headers ⇒ Object
Returns the value of attribute headers.
12 13 14 |
# File 'lib/twitter/rest/request.rb', line 12 def headers @headers end |
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/twitter/rest/request.rb', line 12 def @options end |
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/twitter/rest/request.rb', line 12 def path @path end |
#rate_limit ⇒ Object
Returns the value of attribute rate_limit.
12 13 14 |
# File 'lib/twitter/rest/request.rb', line 12 def rate_limit @rate_limit end |
#request_method ⇒ Object Also known as: verb
Returns the value of attribute request_method.
12 13 14 |
# File 'lib/twitter/rest/request.rb', line 12 def request_method @request_method end |
#uri ⇒ Object
Returns the value of attribute uri.
12 13 14 |
# File 'lib/twitter/rest/request.rb', line 12 def uri @uri end |
Instance Method Details
#perform ⇒ Array, Hash
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/twitter/rest/request.rb', line 30 def perform @headers = Twitter::Headers.new(@client, @request_method, @uri.to_s, @options).request_headers begin response = @client.connection.send(@request_method, @path, @options) { |request| request.headers.update(@headers) }.env rescue Faraday::Error::TimeoutError, Timeout::Error => error raise(Twitter::Error::RequestTimeout.new(error)) rescue Faraday::Error::ClientError, JSON::ParserError => error raise(Twitter::Error.new(error)) end @rate_limit = Twitter::RateLimit.new(response.response_headers) response.body end |