Class: Rubycent::Request
- Inherits:
-
Object
- Object
- Rubycent::Request
- Defined in:
- lib/rubycent/request.rb
Overview
Rubycent::Request
Holds request call and response handling logic
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(endpoint, params, body = nil, headers = {}) ⇒ Request
constructor
A new instance of Request.
-
#post ⇒ Hash
Perform POST request to centrifugo API.
Constructor Details
#initialize(endpoint, params, body = nil, headers = {}) ⇒ Request
Returns a new instance of Request.
29 30 31 32 33 34 |
# File 'lib/rubycent/request.rb', line 29 def initialize(endpoint, params, body = nil, headers = {}) @endpoint = endpoint @params = params @body = body @headers = headers end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
11 12 13 |
# File 'lib/rubycent/request.rb', line 11 def body @body end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
11 12 13 |
# File 'lib/rubycent/request.rb', line 11 def endpoint @endpoint end |
#headers ⇒ Object
Returns the value of attribute headers.
11 12 13 |
# File 'lib/rubycent/request.rb', line 11 def headers @headers end |
#params ⇒ Object
Returns the value of attribute params.
11 12 13 |
# File 'lib/rubycent/request.rb', line 11 def params @params end |
Instance Method Details
#post ⇒ Hash
Perform POST request to centrifugo API
42 43 44 45 46 47 48 49 50 |
# File 'lib/rubycent/request.rb', line 42 def post response = rest_client.post(@endpoint) do |request| configure_request(request: request, body: body, headers: headers) end handle_response(response) rescue Faraday::ConnectionFailed => e handle_error(e) end |