Class: Logi::HttpClient
- Inherits:
-
Object
- Object
- Logi::HttpClient
- Defined in:
- lib/logi/http_client.rb
Overview
Minimal HTTP client using Net::HTTP. Keeps dependencies light.
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#session_cookie ⇒ Object
Returns the value of attribute session_cookie.
Instance Method Summary collapse
- #delete(path) ⇒ Object
- #get(path, params: {}) ⇒ Object
-
#initialize(base_url:, api_key: nil, session_cookie: nil) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #patch(path, body: nil) ⇒ Object
- #post(path, body: nil, params: {}) ⇒ Object
Constructor Details
#initialize(base_url:, api_key: nil, session_cookie: nil) ⇒ HttpClient
Returns a new instance of HttpClient.
16 17 18 19 20 |
# File 'lib/logi/http_client.rb', line 16 def initialize(base_url:, api_key: nil, session_cookie: nil) @base_url = base_url.chomp("/") @api_key = api_key @session_cookie = end |
Instance Attribute Details
#session_cookie ⇒ Object
Returns the value of attribute session_cookie.
22 23 24 |
# File 'lib/logi/http_client.rb', line 22 def @session_cookie end |
Instance Method Details
#delete(path) ⇒ Object
36 37 38 |
# File 'lib/logi/http_client.rb', line 36 def delete(path) request(:delete, path) end |
#get(path, params: {}) ⇒ Object
24 25 26 |
# File 'lib/logi/http_client.rb', line 24 def get(path, params: {}) request(:get, path, params: params) end |
#patch(path, body: nil) ⇒ Object
32 33 34 |
# File 'lib/logi/http_client.rb', line 32 def patch(path, body: nil) request(:patch, path, body: body) end |
#post(path, body: nil, params: {}) ⇒ Object
28 29 30 |
# File 'lib/logi/http_client.rb', line 28 def post(path, body: nil, params: {}) request(:post, path, body: body, params: params) end |