synsbasen_api 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7eae796f59f57889dba53b55e321dff632935a108f5e5697a171907c9d59ba3e
4
- data.tar.gz: 308637d66c60bab9443403ebc9dc80ef8d989368ab73c231a5a90c8076b3c858
3
+ metadata.gz: d169ace3b2a055d9a58f5aedb156b793141f708880bff4d778e6b0bc1f8fd360
4
+ data.tar.gz: b85ee851a3ceb4c32aa23c8adfb7f3f8eca22e51024d4008d5430917c1830f39
5
5
  SHA512:
6
- metadata.gz: '079ec0f9cfec921aa4af2469add7dc3cda8d207bf1644ef2e9250c31adbf65d8a1d4da278b931f6cea69ed3c0c4a8c3b7575f073b250559a8fe4e5113bfb86ff'
7
- data.tar.gz: 26060a57d7ce0a782a3d7b4f6bd4ebf426240a2ceae0c1b66504e58d77427d06e5e292a0e9b96b56c6037ccc7a34590426876369407d9523c251a76f6159a8ff
6
+ metadata.gz: '03781a6e35010f73ac7246478e6601fae1267cd4f4f465187750eaedcd12a64b0dd3bd480713784655d54c5a0cc0fa7848d05ec27f9a75ebf1a3640dd298a429'
7
+ data.tar.gz: b1f8eab40710a624717854888e6edaca54b70e500577c332068691b2e6d0e35cd7fb78805c5da18ee396156e662bb700ae270c052efd4d1019deb2baaa2388c8
@@ -51,6 +51,25 @@ module SynsbasenApi
51
51
  ApiResponse.new(parse_json(response.body))
52
52
  end
53
53
 
54
+ # Sends a DELETE request to Synsbasen API.
55
+ #
56
+ # @param path [String] The API endpoint path.
57
+ # @param params [Hash] Query parameters for the request.
58
+ # @param body [Hash] Request body.
59
+ # @return [ApiResponse] The API response.
60
+ # @raise [ClientError, ServerError] Raised for client or server errors.
61
+ def delete(path, params = {}, body = {})
62
+ request = build_request(path, method: Net::HTTP::Delete, params: params, body: body)
63
+
64
+ response = connection.request(request)
65
+
66
+ raise_errors(response)
67
+
68
+ handle_after_request_callback(response)
69
+
70
+ ApiResponse.new(parse_json(response.body))
71
+ end
72
+
54
73
  private
55
74
 
56
75
  # Establishes and returns a connection to Synsbasen API.
@@ -119,6 +138,8 @@ module SynsbasenApi
119
138
  # @param data [String] The JSON string to parse.
120
139
  # @return [Hash] The parsed JSON string as a hash with symbolized keys.
121
140
  def parse_json(data)
141
+ data ||= "{}"
142
+
122
143
  deep_symbolize_keys(JSON.parse(data))
123
144
  end
124
145
 
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SynsbasenApi
4
+ # The `ErrorCode` class provides methods for interacting with error code related
5
+ # endpoints in the Synsbasen API.
6
+ class ErrorCode < Resource
7
+ extend Searchable
8
+
9
+ class << self
10
+ private
11
+
12
+ def resource_name
13
+ "error_codes"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SynsbasenApi
4
+ # The `WatchedVehicle` class provides methods for interacting with watched vehicle related
5
+ # endpoints in the Synsbasen API.
6
+ class WatchedVehicle < Resource
7
+ class << self
8
+ # Retrieves all watched vehicles.
9
+ #
10
+ # @return [ApiResponse] An instance of `ApiResponse` containing details
11
+ # of all watched vehicles.
12
+ def all
13
+ get("/v1/#{resource_name}")
14
+ end
15
+
16
+ # Creates a new watched vehicle.
17
+ #
18
+ # @param vehicle_id [Integer] The ID of the vehicle to be watched.
19
+ # @return [ApiResponse] An instance of `ApiResponse` containing details
20
+ # of the newly created watched vehicle.
21
+ def subscribe(vehicle_id)
22
+ post("/v1/#{resource_name}", body: { vehicle_id: vehicle_id })
23
+ end
24
+
25
+ # Deletes a watched vehicle.
26
+ #
27
+ # @param vehicle_id [Integer] The ID of the vehicle to be unwatched.
28
+ # @return [ApiResponse] An instance of `ApiResponse` indicating the success
29
+ # of the unwatch operation.
30
+ def unsubscribe(vehicle_id)
31
+ delete("/v1/#{resource_name}/#{vehicle_id}")
32
+ end
33
+
34
+ private
35
+
36
+ def resource_name
37
+ "watched_vehicles"
38
+ end
39
+ end
40
+ end
41
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module SynsbasenApi
4
4
  # The `VERSION` module specifies the version of the SynsbasenApi gem.
5
- VERSION = "1.0.9"
5
+ VERSION = "1.0.10"
6
6
  end
data/lib/synsbasen_api.rb CHANGED
@@ -5,14 +5,15 @@ require "synsbasen_api/resource"
5
5
  require "synsbasen_api/findable"
6
6
  require "synsbasen_api/searchable"
7
7
  require "synsbasen_api/resources/brand"
8
+ require "synsbasen_api/resources/error_code"
8
9
  require "synsbasen_api/resources/inspection"
9
- require "synsbasen_api/resources/inspection_test_center"
10
10
  require "synsbasen_api/resources/leasing_period"
11
11
  require "synsbasen_api/resources/model"
12
12
  require "synsbasen_api/resources/test_center"
13
13
  require "synsbasen_api/resources/variant"
14
14
  require "synsbasen_api/resources/vehicle"
15
15
  require "synsbasen_api/resources/version"
16
+ require "synsbasen_api/resources/watched_vehicle"
16
17
  require "ostruct"
17
18
 
18
19
  # The `SynsbasenApi` module provides a configuration mechanism and requires various
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synsbasen_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Poulsen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-10-19 00:00:00.000000000 Z
12
+ date: 2025-02-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Synsbasen API is the easiest way to get access to the Danish vehicle
15
15
  registry. See https://api.synsbasen.dk for details.
@@ -27,14 +27,15 @@ files:
27
27
  - lib/synsbasen_api/findable.rb
28
28
  - lib/synsbasen_api/resource.rb
29
29
  - lib/synsbasen_api/resources/brand.rb
30
+ - lib/synsbasen_api/resources/error_code.rb
30
31
  - lib/synsbasen_api/resources/inspection.rb
31
- - lib/synsbasen_api/resources/inspection_test_center.rb
32
32
  - lib/synsbasen_api/resources/leasing_period.rb
33
33
  - lib/synsbasen_api/resources/model.rb
34
34
  - lib/synsbasen_api/resources/test_center.rb
35
35
  - lib/synsbasen_api/resources/variant.rb
36
36
  - lib/synsbasen_api/resources/vehicle.rb
37
37
  - lib/synsbasen_api/resources/version.rb
38
+ - lib/synsbasen_api/resources/watched_vehicle.rb
38
39
  - lib/synsbasen_api/searchable.rb
39
40
  - lib/synsbasen_api/version.rb
40
41
  homepage: https://github.com/Synsbasen/synsbasen-api-ruby
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SynsbasenApi
4
- # The `InspectionTestCenter` class provides methods for interacting with inspection test center-related
5
- # endpoints in the Synsbasen API.
6
- class InspectionTestCenter < Resource
7
- extend Searchable
8
-
9
- class << self
10
- # Retrieves information about all inspection test centers.
11
- #
12
- # @return [ApiResponse] An instance of `ApiResponse` containing details
13
- # of all inspection test centers.
14
- def all
15
- get("/v1/#{resource_name}")
16
- end
17
-
18
- private
19
-
20
- def resource_name
21
- "inspection_test_centers"
22
- end
23
- end
24
- end
25
- end