Class: Cent::HTTP
- Inherits:
-
Object
- Object
- Cent::HTTP
- Defined in:
- lib/cent/http.rb
Overview
Cent::HTTP
Holds request call and response handling logic
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#initialize(connection:) ⇒ HTTP
constructor
A new instance of HTTP.
-
#post(body: nil) ⇒ Hash
Perform POST request to centrifugo API.
Constructor Details
#initialize(connection:) ⇒ HTTP
Returns a new instance of HTTP.
28 29 30 |
# File 'lib/cent/http.rb', line 28 def initialize(connection:) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
24 25 26 |
# File 'lib/cent/http.rb', line 24 def connection @connection end |
Instance Method Details
#post(body: nil) ⇒ Hash
Perform POST request to centrifugo API
39 40 41 42 43 44 45 |
# File 'lib/cent/http.rb', line 39 def post(body: nil) response = connection.post(nil, body) raise ResponseError.new(**response.body['error'].transform_keys(&:to_sym)) if response.body.key?('error') response.body end |