Class: Square::HttpClient
- Inherits:
-
Object
- Object
- Square::HttpClient
- Defined in:
- lib/square/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.
23 24 25 26 |
# File 'lib/square/http/http_client.rb', line 23 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.
90 91 92 93 94 95 96 97 |
# File 'lib/square/http/http_client.rb', line 90 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.
16 17 18 19 |
# File 'lib/square/http/http_client.rb', line 16 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.
9 10 11 12 |
# File 'lib/square/http/http_client.rb', line 9 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.
31 32 33 34 35 36 |
# File 'lib/square/http/http_client.rb', line 31 def get(query_url, headers: {}) HttpRequest.new(HttpMethodEnum::GET, query_url, headers: headers) end |
#head(query_url, headers: {}) ⇒ Object
Get a HEAD HttpRequest object.
41 42 43 44 45 46 |
# File 'lib/square/http/http_client.rb', line 41 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.
78 79 80 81 82 83 84 85 |
# File 'lib/square/http/http_client.rb', line 78 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.
52 53 54 55 56 57 58 59 |
# File 'lib/square/http/http_client.rb', line 52 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.
65 66 67 68 69 70 71 72 |
# File 'lib/square/http/http_client.rb', line 65 def put(query_url, headers: {}, parameters: {}) HttpRequest.new(HttpMethodEnum::PUT, query_url, headers: headers, parameters: parameters) end |