Class: Hyperclient::HTTP Private
- Inherits:
-
Object
- Object
- Hyperclient::HTTP
- Extended by:
- Forwardable
- Includes:
- HTTParty
- Defined in:
- lib/hyperclient/http.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This class wrapps HTTParty and performs the HTTP requests for a resource.
Instance Method Summary collapse
-
#authenticate(options) ⇒ void
private
private
Sets the authenitcation method for HTTParty.
-
#delete ⇒ Object
Sends a DELETE request the the resource url.
-
#get ⇒ Object
Sends a GET request the the resource url.
-
#head ⇒ Object
Sends a HEAD request the the resource url.
-
#initialize(resource, options = {}) ⇒ HTTP
constructor
Initializes a HTTP agent.
-
#options ⇒ Object
Sends an OPTIONS request the the resource url.
-
#post(params) ⇒ Object
Sends a POST request the the resource url.
-
#put(params) ⇒ Object
Sends a PUT request the the resource url.
Constructor Details
#initialize(resource, options = {}) ⇒ HTTP
Initializes a HTTP agent.
25 26 27 28 |
# File 'lib/hyperclient/http.rb', line 25 def initialize(resource, = {}) @resource = resource authenticate([:auth]) if && .include?(:auth) end |
Instance Method Details
#authenticate(options) ⇒ void (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Sets the authenitcation method for HTTParty.
85 86 87 88 |
# File 'lib/hyperclient/http.rb', line 85 def authenticate() auth_method = [:type].to_s + '_auth' self.class.send(auth_method, *[:credentials]) end |
#delete ⇒ Object
Sends a DELETE request the the resource url.
72 73 74 |
# File 'lib/hyperclient/http.rb', line 72 def delete self.class.delete(url) end |
#get ⇒ Object
Sends a GET request the the resource url.
33 34 35 |
# File 'lib/hyperclient/http.rb', line 33 def get self.class.get(url).parsed_response end |
#head ⇒ Object
Sends a HEAD request the the resource url.
65 66 67 |
# File 'lib/hyperclient/http.rb', line 65 def head self.class.head(url) end |
#options ⇒ Object
Sends an OPTIONS request the the resource url.
58 59 60 |
# File 'lib/hyperclient/http.rb', line 58 def self.class.(url) end |
#post(params) ⇒ Object
Sends a POST request the the resource url.
42 43 44 |
# File 'lib/hyperclient/http.rb', line 42 def post(params) self.class.post(url, body: params) end |
#put(params) ⇒ Object
Sends a PUT request the the resource url.
51 52 53 |
# File 'lib/hyperclient/http.rb', line 51 def put(params) self.class.put(url, body: params) end |