Class: Asdawqw::HttpClient
- Inherits:
-
Object
- Object
- Asdawqw::HttpClient
- Defined in:
- lib/asdawqw/http/http_client.rb
Overview
An interface for the methods that an HTTP Client must implement.
This class should not be instantiated but should be used as a base class for HTTP Client classes.
Direct Known Subclasses
Instance Method Summary collapse
-
#convert_response(_response) ⇒ Object
Converts the HTTP Response from the client to an HttpResponse object.
-
#delete(query_url, headers: {}, parameters: {}) ⇒ Object
Get a DELETE HttpRequest object.
-
#execute_as_binary(_http_request) ⇒ Object
Execute an HttpRequest when the response is expected to be binary.
-
#execute_as_string(_http_request) ⇒ Object
Execute an HttpRequest when the response is expected to be a string.
-
#get(query_url, headers: {}) ⇒ Object
Get a GET HttpRequest object.
-
#head(query_url, headers: {}) ⇒ Object
Get a HEAD HttpRequest object.
-
#patch(query_url, headers: {}, parameters: {}) ⇒ Object
Get a PATCH HttpRequest object.
-
#post(query_url, headers: {}, parameters: {}) ⇒ Object
Get a POST HttpRequest object.
-
#put(query_url, headers: {}, parameters: {}) ⇒ Object
Get a PUT HttpRequest object.
Instance Method Details
#convert_response(_response) ⇒ Object
Converts the HTTP Response from the client to an HttpResponse object.
28 29 30 31 |
# File 'lib/asdawqw/http/http_client.rb', line 28 def convert_response(_response) raise NotImplementedError, 'This method needs to be implemented in a child class.' end |
#delete(query_url, headers: {}, parameters: {}) ⇒ Object
Get a DELETE HttpRequest object.
95 96 97 98 99 100 101 102 |
# File 'lib/asdawqw/http/http_client.rb', line 95 def delete(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::DELETE, query_url, headers: headers, parameters: parameters) end |
#execute_as_binary(_http_request) ⇒ Object
Execute an HttpRequest when the response is expected to be binary.
21 22 23 24 |
# File 'lib/asdawqw/http/http_client.rb', line 21 def execute_as_binary(_http_request) raise NotImplementedError, 'This method needs to be implemented in a child class.' end |
#execute_as_string(_http_request) ⇒ Object
Execute an HttpRequest when the response is expected to be a string.
14 15 16 17 |
# File 'lib/asdawqw/http/http_client.rb', line 14 def execute_as_string(_http_request) raise NotImplementedError, 'This method needs to be implemented in a child class.' end |
#get(query_url, headers: {}) ⇒ Object
Get a GET HttpRequest object.
36 37 38 39 40 41 |
# File 'lib/asdawqw/http/http_client.rb', line 36 def get(query_url, headers: {}) HttpRequest.new(HttpMethodEnum::GET, query_url, headers: headers) end |
#head(query_url, headers: {}) ⇒ Object
Get a HEAD HttpRequest object.
46 47 48 49 50 51 |
# File 'lib/asdawqw/http/http_client.rb', line 46 def head(query_url, headers: {}) HttpRequest.new(HttpMethodEnum::HEAD, query_url, headers: headers) end |
#patch(query_url, headers: {}, parameters: {}) ⇒ Object
Get a PATCH HttpRequest object.
83 84 85 86 87 88 89 90 |
# File 'lib/asdawqw/http/http_client.rb', line 83 def patch(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::PATCH, query_url, headers: headers, parameters: parameters) end |
#post(query_url, headers: {}, parameters: {}) ⇒ Object
Get a POST HttpRequest object.
57 58 59 60 61 62 63 64 |
# File 'lib/asdawqw/http/http_client.rb', line 57 def post(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::POST, query_url, headers: headers, parameters: parameters) end |
#put(query_url, headers: {}, parameters: {}) ⇒ Object
Get a PUT HttpRequest object.
70 71 72 73 74 75 76 77 |
# File 'lib/asdawqw/http/http_client.rb', line 70 def put(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::PUT, query_url, headers: headers, parameters: parameters) end |