Class: SynsbasenApi::Client
- Inherits:
-
Object
- Object
- SynsbasenApi::Client
- Defined in:
- lib/synsbasen_api/client.rb
Overview
The Client
class serves as the base class for interacting with the Synsbasen API.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_BASE_URL =
"https://api.synsbasen.dk".freeze
Class Method Summary collapse
-
.delete(path, params = {}, body = {}) ⇒ ApiResponse
Sends a DELETE request to Synsbasen API.
-
.get(path, params: {}, expand: []) ⇒ ApiResponse
Sends a GET request to Synsbasen API.
-
.post(path, params: {}, body: {}, expand: []) ⇒ ApiResponse
Sends a POST request to Synsbasen API.
Class Method Details
.delete(path, params = {}, body = {}) ⇒ ApiResponse
Sends a DELETE request to Synsbasen API.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/synsbasen_api/client.rb', line 61 def delete(path, params = {}, body = {}) request = build_request(path, method: Net::HTTP::Delete, params: params, body: body) response = connection.request(request) raise_errors(response) handle_after_request_callback(response) ApiResponse.new(parse_json(response.body)) end |
.get(path, params: {}, expand: []) ⇒ ApiResponse
Sends a GET request to Synsbasen API.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/synsbasen_api/client.rb', line 22 def get(path, params: {}, expand: []) request = build_request(path, method: Net::HTTP::Get, params: params, expand: ) response = connection.request(request) raise_errors(response) handle_after_request_callback(response) ApiResponse.new(parse_json(response.body)) end |
.post(path, params: {}, body: {}, expand: []) ⇒ ApiResponse
Sends a POST request to Synsbasen API.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/synsbasen_api/client.rb', line 42 def post(path, params: {}, body: {}, expand: []) request = build_request(path, method: Net::HTTP::Post, params: params, body: body, expand: ) response = connection.request(request) raise_errors(response) handle_after_request_callback(response) ApiResponse.new(parse_json(response.body)) end |