synsbasen_api 1.0.6 → 1.0.8
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 +4 -4
- data/lib/synsbasen_api/client.rb +96 -44
- data/lib/synsbasen_api/findable.rb +18 -0
- data/lib/synsbasen_api/resource.rb +17 -0
- data/lib/synsbasen_api/resources/brand.rb +11 -11
- data/lib/synsbasen_api/resources/inspection.rb +7 -14
- data/lib/synsbasen_api/resources/inspection_test_center.rb +10 -2
- data/lib/synsbasen_api/resources/leasing_period.rb +15 -0
- data/lib/synsbasen_api/resources/model.rb +11 -11
- data/lib/synsbasen_api/resources/test_center.rb +8 -2
- data/lib/synsbasen_api/resources/variant.rb +11 -11
- data/lib/synsbasen_api/resources/vehicle.rb +10 -25
- data/lib/synsbasen_api/resources/version.rb +11 -11
- data/lib/synsbasen_api/searchable.rb +23 -0
- data/lib/synsbasen_api/version.rb +1 -1
- data/lib/synsbasen_api.rb +6 -1
- metadata +7 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de87965f69a8b280b6520272e6bc6cc005ba5573052015e80d5eaad9f82dde9f
|
4
|
+
data.tar.gz: 46a3bbab6a5d51f3b843ab008be9d5e292ef3235035cb943cf631f653891ab90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87360c58515dc8a084bcf08f02435e5320989f13bdc06d17ec391e9ee8e1492546c2adafa6f1c0bad310fdd6b88c7397449f917038e3e244201ae7f8a6e8452d
|
7
|
+
data.tar.gz: d4904776df894bb5e2dac117ec719202b98ac4ed84054e78238372997d08839504475211cbf3321e34e3f3d9141731b5b8f717a3b50a5e0be1f00427024ede40
|
data/lib/synsbasen_api/client.rb
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
require "synsbasen_api/api_response"
|
4
4
|
require "synsbasen_api/error"
|
5
|
-
require "
|
6
|
-
require "
|
7
|
-
require "
|
8
|
-
require "active_support/core_ext/enumerable"
|
5
|
+
require "net/http"
|
6
|
+
require "uri"
|
7
|
+
require "json"
|
9
8
|
|
10
9
|
module SynsbasenApi
|
11
10
|
# The `Client` class serves as the base class for interacting with the Synsbasen API.
|
@@ -13,86 +12,139 @@ module SynsbasenApi
|
|
13
12
|
DEFAULT_BASE_URL = "https://api.synsbasen.dk".freeze
|
14
13
|
|
15
14
|
class << self
|
16
|
-
#
|
17
|
-
#
|
18
|
-
# @return [Faraday::Connection] A Faraday connection instance.
|
19
|
-
def connection
|
20
|
-
@_connection ||= Faraday.new(url: SynsbasenApi.config[:base_url] || DEFAULT_BASE_URL) do |conn|
|
21
|
-
conn.use Faraday::Response::RaiseError
|
22
|
-
conn.headers = {
|
23
|
-
'Content-Type' => 'application/json',
|
24
|
-
'Authorization' => 'Bearer ' + SynsbasenApi.config[:api_key],
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Sends a GET request to the Synsbasen API.
|
15
|
+
# Sends a GET request to Synsbasen API.
|
30
16
|
#
|
31
17
|
# @param path [String] The API endpoint path.
|
32
18
|
# @param params [Hash] Query parameters for the request.
|
33
|
-
# @param
|
19
|
+
# @param expand [Array] List of fields to expand in the response.
|
34
20
|
# @return [ApiResponse] An instance of `ApiResponse` containing the API response.
|
35
21
|
# @raise [ClientError, ServerError] Raised for client or server errors.
|
36
22
|
def get(path, params: {}, expand: [])
|
37
|
-
|
38
|
-
|
39
|
-
|
23
|
+
request = build_request(path, method: Net::HTTP::Get, params: params, expand: expand)
|
24
|
+
|
25
|
+
response = connection.request(request)
|
26
|
+
|
27
|
+
raise_errors(response)
|
40
28
|
|
41
29
|
handle_after_request_callback(response)
|
42
30
|
|
43
|
-
ApiResponse.new(
|
44
|
-
rescue => e
|
45
|
-
rescue_and_raise_errors(e)
|
31
|
+
ApiResponse.new(parse_json(response.body))
|
46
32
|
end
|
47
33
|
|
48
|
-
# Sends a POST request to
|
34
|
+
# Sends a POST request to Synsbasen API.
|
49
35
|
#
|
50
36
|
# @param path [String] The API endpoint path.
|
51
37
|
# @param params [Hash] Query parameters for the request.
|
52
38
|
# @param body [Hash] Request body.
|
39
|
+
# @param expand [Array] List of fields to expand in the response.
|
53
40
|
# @return [ApiResponse] An instance of `ApiResponse` containing the API response.
|
54
41
|
# @raise [ClientError, ServerError] Raised for client or server errors.
|
55
42
|
def post(path, params: {}, body: {}, expand: [])
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
43
|
+
request = build_request(path, method: Net::HTTP::Post, params: params, body: body, expand: expand)
|
44
|
+
|
45
|
+
response = connection.request(request)
|
46
|
+
|
47
|
+
raise_errors(response)
|
60
48
|
|
61
49
|
handle_after_request_callback(response)
|
62
50
|
|
63
|
-
ApiResponse.new(
|
64
|
-
rescue => e
|
65
|
-
rescue_and_raise_errors(e)
|
51
|
+
ApiResponse.new(parse_json(response.body))
|
66
52
|
end
|
67
53
|
|
68
54
|
private
|
69
55
|
|
70
|
-
#
|
56
|
+
# Establishes and returns a connection to Synsbasen API.
|
57
|
+
#
|
58
|
+
# @return [Net::HTTP] A Net::HTTP connection instance.
|
59
|
+
def connection
|
60
|
+
uri = URI.parse(SynsbasenApi.config[:base_url] || DEFAULT_BASE_URL)
|
61
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
62
|
+
http.use_ssl = uri.scheme == "https"
|
63
|
+
http
|
64
|
+
end
|
65
|
+
|
66
|
+
# Builds a Net::HTTP request object with the specified parameters.
|
67
|
+
#
|
68
|
+
# @param path [String] The API endpoint path.
|
69
|
+
# @param params [Hash] Query parameters for the request.
|
70
|
+
# @param body [Hash] Request body.
|
71
|
+
# @param expand [Array] List of fields to expand in the response.
|
72
|
+
# @param method [Net::HTTP::Get, Net::HTTP::Post] The HTTP method to use.
|
73
|
+
#
|
74
|
+
# @return [Net::HTTP::Get, Net::HTTP::Post] A Net::HTTP request object.
|
75
|
+
def build_request(path, method:, params: {}, body: {}, expand: [])
|
76
|
+
uri = URI.parse(SynsbasenApi.config[:base_url] || DEFAULT_BASE_URL)
|
77
|
+
uri.path = path
|
78
|
+
query = params
|
79
|
+
query.merge!('expand[]': expand) unless expand.nil? || expand.empty?
|
80
|
+
uri.query = URI.encode_www_form(query)
|
81
|
+
|
82
|
+
request = method.new(uri)
|
83
|
+
request.body = body.reject { |i| i.nil? || i.empty? }.to_json if method == Net::HTTP::Post
|
84
|
+
request["Content-Type"] = "application/json"
|
85
|
+
request["Authorization"] = "Bearer #{SynsbasenApi.config[:api_key]}"
|
86
|
+
|
87
|
+
request
|
88
|
+
end
|
89
|
+
|
90
|
+
# Raises specific errors based on the type of Net::HTTP error encountered.
|
71
91
|
#
|
72
92
|
# @param e [Exception] The exception to handle.
|
73
93
|
# @raise [ClientError, ServerError] Raised for client or server errors.
|
74
|
-
def
|
75
|
-
case
|
76
|
-
when
|
77
|
-
raise ClientError.new(
|
78
|
-
when
|
79
|
-
raise ClientError.new(
|
80
|
-
when
|
81
|
-
raise ServerError.new(
|
94
|
+
def raise_errors(response)
|
95
|
+
case response
|
96
|
+
when Net::HTTPUnauthorized
|
97
|
+
raise ClientError.new(response.message, response.code, {})
|
98
|
+
when Net::HTTPClientError, Net::HTTPBadRequest, Net::HTTPForbidden, Net::HTTPNotFound
|
99
|
+
raise ClientError.new(response.message, response.code, parse_json(response.body))
|
100
|
+
when Net::HTTPServerError
|
101
|
+
raise ServerError.new(response.message, response.code, {})
|
82
102
|
else
|
83
|
-
|
103
|
+
response
|
84
104
|
end
|
85
105
|
end
|
86
106
|
|
87
107
|
# Calls the after_request callback if configured in the SynsbasenApi.
|
88
108
|
#
|
89
|
-
# @param response [
|
109
|
+
# @param response [Net::HTTPResponse] The Net::HTTPResponse object.
|
90
110
|
# @return [void]
|
91
111
|
def handle_after_request_callback(response)
|
92
112
|
return unless SynsbasenApi.config[:after_request]
|
93
113
|
|
94
114
|
SynsbasenApi.config[:after_request].call(response)
|
95
115
|
end
|
116
|
+
|
117
|
+
# Parses a JSON string into a hash with symbolized keys.
|
118
|
+
#
|
119
|
+
# @param data [String] The JSON string to parse.
|
120
|
+
# @return [Hash] The parsed JSON string as a hash with symbolized keys.
|
121
|
+
def parse_json(data)
|
122
|
+
deep_symbolize_keys(JSON.parse(data))
|
123
|
+
end
|
124
|
+
|
125
|
+
# Recursively converts all keys in a hash to symbols.
|
126
|
+
#
|
127
|
+
# This method is used to convert all keys in the API response to symbols.
|
128
|
+
#
|
129
|
+
# @param hash [Hash] The hash to convert.
|
130
|
+
# @return [Hash] The hash with all keys converted to symbols.
|
131
|
+
# @example
|
132
|
+
# deep_symbolize_keys({ "key" => "value" }) #=> { key: "value" }
|
133
|
+
# deep_symbolize_keys({ "key" => { "nested_key" => "value" } }) #=> { key: { nested_key: "value" } }
|
134
|
+
def deep_symbolize_keys(obj)
|
135
|
+
case obj
|
136
|
+
when Hash
|
137
|
+
obj.each_with_object({}) do |(key, value), result|
|
138
|
+
new_key = key.is_a?(String) ? key.to_sym : key
|
139
|
+
new_value = deep_symbolize_keys(value)
|
140
|
+
result[new_key] = new_value
|
141
|
+
end
|
142
|
+
when Array
|
143
|
+
obj.map { |value| deep_symbolize_keys(value) }
|
144
|
+
else
|
145
|
+
obj
|
146
|
+
end
|
147
|
+
end
|
96
148
|
end
|
97
149
|
end
|
98
150
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SynsbasenApi
|
4
|
+
# Provides a method to find a resource by its ID.
|
5
|
+
#
|
6
|
+
# This module is intended to be extended in classes that represent resources.
|
7
|
+
module Findable
|
8
|
+
# Retrieves information about a specific record based on its ID.
|
9
|
+
#
|
10
|
+
# @param id [String] The unique identifier of the record.
|
11
|
+
# @param expand [Array<String>] A list of related resources to include in the response.
|
12
|
+
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
13
|
+
# of the specified version.
|
14
|
+
def find(id, expand: [])
|
15
|
+
get("/v1/#{resource_name}/#{id}", expand: expand)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SynsbasenApi
|
4
|
+
class Resource < Client
|
5
|
+
class << self
|
6
|
+
private
|
7
|
+
|
8
|
+
# Define the resource name
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
# @raise [NotImplementedError] if the method is not implemented by the subclass
|
12
|
+
def resource_name
|
13
|
+
raise NotImplementedError, 'Subclasses must implement this method'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -3,23 +3,23 @@
|
|
3
3
|
module SynsbasenApi
|
4
4
|
# The `Brand` class provides methods for interacting with brand-related
|
5
5
|
# endpoints in the Synsbasen API.
|
6
|
-
class Brand <
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
# @param id [String] The unique identifier of the brand.
|
11
|
-
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
12
|
-
# of the specified brand.
|
13
|
-
def find(id, expand: [])
|
14
|
-
get("/v1/brands/#{id}", expand: expand)
|
15
|
-
end
|
6
|
+
class Brand < Resource
|
7
|
+
extend Findable
|
8
|
+
extend Searchable
|
16
9
|
|
10
|
+
class << self
|
17
11
|
# Retrieves information about all brands.
|
18
12
|
#
|
19
13
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
20
14
|
# of all brands.
|
21
15
|
def all(expand: [])
|
22
|
-
get("/v1
|
16
|
+
get("/v1/#{resource_name}", expand: expand)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def resource_name
|
22
|
+
"brands"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -3,21 +3,14 @@
|
|
3
3
|
module SynsbasenApi
|
4
4
|
# The `Inspection` class provides methods for interacting with inspection-related
|
5
5
|
# endpoints in the Synsbasen API.
|
6
|
-
class Inspection <
|
6
|
+
class Inspection < Resource
|
7
|
+
extend Searchable
|
8
|
+
|
7
9
|
class << self
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# @return [ApiResponse] An instance of `ApiResponse` containing search results.
|
13
|
-
def search(args = {}, expand: [])
|
14
|
-
post(
|
15
|
-
"/v1/inspections/search",
|
16
|
-
body: {
|
17
|
-
method: 'SELECT',
|
18
|
-
}.merge(args),
|
19
|
-
expand: expand
|
20
|
-
)
|
10
|
+
private
|
11
|
+
|
12
|
+
def resource_name
|
13
|
+
"inspections"
|
21
14
|
end
|
22
15
|
end
|
23
16
|
end
|
@@ -3,14 +3,22 @@
|
|
3
3
|
module SynsbasenApi
|
4
4
|
# The `InspectionTestCenter` class provides methods for interacting with inspection test center-related
|
5
5
|
# endpoints in the Synsbasen API.
|
6
|
-
class InspectionTestCenter <
|
6
|
+
class InspectionTestCenter < Resource
|
7
|
+
extend Searchable
|
8
|
+
|
7
9
|
class << self
|
8
10
|
# Retrieves information about all inspection test centers.
|
9
11
|
#
|
10
12
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
11
13
|
# of all inspection test centers.
|
12
14
|
def all
|
13
|
-
get("/v1
|
15
|
+
get("/v1/#{resource_name}")
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def resource_name
|
21
|
+
"inspection_test_centers"
|
14
22
|
end
|
15
23
|
end
|
16
24
|
end
|
@@ -3,24 +3,24 @@
|
|
3
3
|
module SynsbasenApi
|
4
4
|
# The `Model` class provides methods for interacting with model-related
|
5
5
|
# endpoints in the Synsbasen API.
|
6
|
-
class Model <
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
# @param id [String] The unique identifier of the model.
|
11
|
-
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
12
|
-
# of the specified model.
|
13
|
-
def find(id, expand: [])
|
14
|
-
get("/v1/models/#{id}", expand: expand)
|
15
|
-
end
|
6
|
+
class Model < Resource
|
7
|
+
extend Findable
|
8
|
+
extend Searchable
|
16
9
|
|
10
|
+
class << self
|
17
11
|
# Retrieves information about all models associated with a given brand.
|
18
12
|
#
|
19
13
|
# @param brand_id [String] The unique identifier of the brand.
|
20
14
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
21
15
|
# of all models associated with the specified brand.
|
22
16
|
def all(brand_id, expand: [])
|
23
|
-
get("/v1/brands/#{brand_id}
|
17
|
+
get("/v1/brands/#{brand_id}/#{resource_name}", expand: expand)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def resource_name
|
23
|
+
"models"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -3,14 +3,20 @@
|
|
3
3
|
module SynsbasenApi
|
4
4
|
# The `TestCenter` class provides methods for interacting with test center-related
|
5
5
|
# endpoints in the Synsbasen API.
|
6
|
-
class TestCenter <
|
6
|
+
class TestCenter < Resource
|
7
7
|
class << self
|
8
8
|
# Retrieves information about all test centers.
|
9
9
|
#
|
10
10
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
11
11
|
# of all test centers.
|
12
12
|
def all
|
13
|
-
get("/v1
|
13
|
+
get("/v1/#{resource_name}")
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def resource_name
|
19
|
+
"test_centers"
|
14
20
|
end
|
15
21
|
end
|
16
22
|
end
|
@@ -3,24 +3,24 @@
|
|
3
3
|
module SynsbasenApi
|
4
4
|
# The `Variant` class provides methods for interacting with variant-related
|
5
5
|
# endpoints in the Synsbasen API.
|
6
|
-
class Variant <
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
# @param id [String] The unique identifier of the variant.
|
11
|
-
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
12
|
-
# of the specified variant.
|
13
|
-
def find(id, expand: [])
|
14
|
-
get("/v1/variants/#{id}", expand: expand)
|
15
|
-
end
|
6
|
+
class Variant < Resource
|
7
|
+
extend Findable
|
8
|
+
extend Searchable
|
16
9
|
|
10
|
+
class << self
|
17
11
|
# Retrieves information about all variants associated with a given model.
|
18
12
|
#
|
19
13
|
# @param model_id [String] The unique identifier of the model.
|
20
14
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
21
15
|
# of all variants associated with the specified model.
|
22
16
|
def all(model_id, expand: [])
|
23
|
-
get("/v1/models/#{model_id}
|
17
|
+
get("/v1/models/#{model_id}/#{resource_name}", expand: expand)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def resource_name
|
23
|
+
"variants"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -5,17 +5,11 @@ require 'cgi/escape'
|
|
5
5
|
module SynsbasenApi
|
6
6
|
# The `Vehicle` class provides methods for interacting with vehicle-related
|
7
7
|
# endpoints in the Synsbasen API. It extends the `Client` class.
|
8
|
-
class Vehicle <
|
9
|
-
|
10
|
-
|
11
|
-
#
|
12
|
-
# @param id [String] The unique identifier of the vehicle.
|
13
|
-
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
14
|
-
# of the specified vehicle.
|
15
|
-
def find(id, expand: [])
|
16
|
-
get("/v1/vehicles/#{id}", expand: expand)
|
17
|
-
end
|
8
|
+
class Vehicle < Resource
|
9
|
+
extend Findable
|
10
|
+
extend Searchable
|
18
11
|
|
12
|
+
class << self
|
19
13
|
# Retrieves information about a vehicle based on its registration number.
|
20
14
|
#
|
21
15
|
# @param registration [String] The registration number of the vehicle.
|
@@ -23,7 +17,7 @@ module SynsbasenApi
|
|
23
17
|
# of the specified vehicle.
|
24
18
|
def find_by_registration(registration, expand: [])
|
25
19
|
escaped_registration = CGI.escape(registration)
|
26
|
-
get("/v1/
|
20
|
+
get("/v1/#{resource_name}/registration/#{escaped_registration}", expand: expand)
|
27
21
|
end
|
28
22
|
|
29
23
|
# Retrieves information about a vehicle based on its VIN (Vehicle Identification Number).
|
@@ -32,22 +26,13 @@ module SynsbasenApi
|
|
32
26
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
33
27
|
# of the specified vehicle.
|
34
28
|
def find_by_vin(vin, expand: [])
|
35
|
-
get("/v1/
|
29
|
+
get("/v1/#{resource_name}/vin/#{vin}", expand: expand)
|
36
30
|
end
|
37
31
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
# @return [ApiResponse] An instance of `ApiResponse` containing search results.
|
43
|
-
def search(args = {}, expand: nil)
|
44
|
-
post(
|
45
|
-
"/v1/vehicles/search",
|
46
|
-
body: {
|
47
|
-
method: 'SELECT',
|
48
|
-
}.merge(args),
|
49
|
-
expand: expand
|
50
|
-
)
|
32
|
+
private
|
33
|
+
|
34
|
+
def resource_name
|
35
|
+
"vehicles"
|
51
36
|
end
|
52
37
|
end
|
53
38
|
end
|
@@ -3,24 +3,24 @@
|
|
3
3
|
module SynsbasenApi
|
4
4
|
# The `Version` class provides methods for interacting with version-related
|
5
5
|
# endpoints in the Synsbasen API.
|
6
|
-
class Version <
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
# @param id [String] The unique identifier of the version.
|
11
|
-
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
12
|
-
# of the specified version.
|
13
|
-
def find(id, expand: [])
|
14
|
-
get("/v1/versions/#{id}", expand: expand)
|
15
|
-
end
|
6
|
+
class Version < Resource
|
7
|
+
extend Findable
|
8
|
+
extend Searchable
|
16
9
|
|
10
|
+
class << self
|
17
11
|
# Retrieves information about all versions associated with a given variant.
|
18
12
|
#
|
19
13
|
# @param variant_id [String] The unique identifier of the variant.
|
20
14
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
21
15
|
# of all versions associated with the specified variant.
|
22
16
|
def all(variant_id, expand: [])
|
23
|
-
get("/v1/variants/#{variant_id}
|
17
|
+
get("/v1/variants/#{variant_id}/#{resource_name}", expand: expand)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def resource_name
|
23
|
+
"versions"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SynsbasenApi
|
4
|
+
# Provides a search method for resources.
|
5
|
+
#
|
6
|
+
# This module is intended to be extended in classes that represent resources.
|
7
|
+
module Searchable
|
8
|
+
# Performs a search for resources based on the provided criteria.
|
9
|
+
#
|
10
|
+
# @param args [Hash] Additional parameters to customize the search.
|
11
|
+
# @option args [String] :method The search method. Default is 'SELECT'.
|
12
|
+
# @return [ApiResponse] An instance of `ApiResponse` containing search results.
|
13
|
+
def search(args = {}, expand: nil)
|
14
|
+
post(
|
15
|
+
"/v1/#{resource_name}/search",
|
16
|
+
body: {
|
17
|
+
method: 'SELECT',
|
18
|
+
}.merge(args),
|
19
|
+
expand: expand
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/synsbasen_api.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "synsbasen_api/client"
|
4
|
+
require "synsbasen_api/resource"
|
5
|
+
require "synsbasen_api/findable"
|
6
|
+
require "synsbasen_api/searchable"
|
4
7
|
require "synsbasen_api/resources/brand"
|
5
8
|
require "synsbasen_api/resources/inspection"
|
6
9
|
require "synsbasen_api/resources/inspection_test_center"
|
10
|
+
require "synsbasen_api/resources/leasing_period"
|
7
11
|
require "synsbasen_api/resources/model"
|
8
12
|
require "synsbasen_api/resources/test_center"
|
9
|
-
require "synsbasen_api/resources/vehicle"
|
10
13
|
require "synsbasen_api/resources/variant"
|
14
|
+
require "synsbasen_api/resources/vehicle"
|
11
15
|
require "synsbasen_api/resources/version"
|
16
|
+
require "ostruct"
|
12
17
|
|
13
18
|
# The `SynsbasenApi` module provides a configuration mechanism and requires various
|
14
19
|
# classes and modules related to interacting with the Synsbasen API.
|
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.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Poulsen
|
@@ -9,36 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: activesupport
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '7'
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '7'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: faraday
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - "~>"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '2.7'
|
35
|
-
type: :runtime
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - "~>"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '2.7'
|
12
|
+
date: 2024-05-06 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
42
14
|
description: Synsbasen API is the easiest way to get access to the Danish vehicle
|
43
15
|
registry. See https://api.synsbasen.dk for details.
|
44
16
|
email:
|
@@ -52,14 +24,18 @@ files:
|
|
52
24
|
- lib/synsbasen_api/api_response.rb
|
53
25
|
- lib/synsbasen_api/client.rb
|
54
26
|
- lib/synsbasen_api/error.rb
|
27
|
+
- lib/synsbasen_api/findable.rb
|
28
|
+
- lib/synsbasen_api/resource.rb
|
55
29
|
- lib/synsbasen_api/resources/brand.rb
|
56
30
|
- lib/synsbasen_api/resources/inspection.rb
|
57
31
|
- lib/synsbasen_api/resources/inspection_test_center.rb
|
32
|
+
- lib/synsbasen_api/resources/leasing_period.rb
|
58
33
|
- lib/synsbasen_api/resources/model.rb
|
59
34
|
- lib/synsbasen_api/resources/test_center.rb
|
60
35
|
- lib/synsbasen_api/resources/variant.rb
|
61
36
|
- lib/synsbasen_api/resources/vehicle.rb
|
62
37
|
- lib/synsbasen_api/resources/version.rb
|
38
|
+
- lib/synsbasen_api/searchable.rb
|
63
39
|
- lib/synsbasen_api/version.rb
|
64
40
|
homepage: https://github.com/Synsbasen/synsbasen-api-ruby
|
65
41
|
licenses:
|