synsbasen_api 1.0.7 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/synsbasen_api/api_response.rb +4 -1
- 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 +8 -15
- 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 +5 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eae796f59f57889dba53b55e321dff632935a108f5e5697a171907c9d59ba3e
|
4
|
+
data.tar.gz: 308637d66c60bab9443403ebc9dc80ef8d989368ab73c231a5a90c8076b3c858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '079ec0f9cfec921aa4af2469add7dc3cda8d207bf1644ef2e9250c31adbf65d8a1d4da278b931f6cea69ed3c0c4a8c3b7575f073b250559a8fe4e5113bfb86ff'
|
7
|
+
data.tar.gz: 26060a57d7ce0a782a3d7b4f6bd4ebf426240a2ceae0c1b66504e58d77427d06e5e292a0e9b96b56c6037ccc7a34590426876369407d9523c251a76f6159a8ff
|
@@ -12,6 +12,9 @@ module SynsbasenApi
|
|
12
12
|
# @return [Boolean] Indicates whether there is more data available in the response.
|
13
13
|
attr_reader :has_more
|
14
14
|
|
15
|
+
# @return [Numeric] The current page number.
|
16
|
+
attr_reader :page
|
17
|
+
|
15
18
|
# @return [Numeric] The total number of pages available.
|
16
19
|
attr_reader :total_pages
|
17
20
|
|
@@ -30,7 +33,7 @@ module SynsbasenApi
|
|
30
33
|
@data = response[:data]
|
31
34
|
@cost = response[:cost]
|
32
35
|
|
33
|
-
%i[has_more total_pages total_count].each do |key|
|
36
|
+
%i[has_more page total_pages total_count].each do |key|
|
34
37
|
instance_variable_set("@#{key}", response[key]) if response.key?(key)
|
35
38
|
end
|
36
39
|
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,29 +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}")
|
14
16
|
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# @return [ApiResponse] An instance of `ApiResponse` containing search results.
|
21
|
-
def search(args = {}, expand: [])
|
22
|
-
post(
|
23
|
-
"/v1/inspection_test_centers/search",
|
24
|
-
body: {
|
25
|
-
method: 'SELECT',
|
26
|
-
}.merge(args),
|
27
|
-
expand: expand
|
28
|
-
)
|
18
|
+
private
|
19
|
+
|
20
|
+
def resource_name
|
21
|
+
"inspection_test_centers"
|
29
22
|
end
|
30
23
|
end
|
31
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,13 +1,17 @@
|
|
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"
|
12
16
|
require "ostruct"
|
13
17
|
|
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.9
|
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-
|
12
|
+
date: 2024-10-19 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.
|
@@ -24,14 +24,18 @@ files:
|
|
24
24
|
- lib/synsbasen_api/api_response.rb
|
25
25
|
- lib/synsbasen_api/client.rb
|
26
26
|
- lib/synsbasen_api/error.rb
|
27
|
+
- lib/synsbasen_api/findable.rb
|
28
|
+
- lib/synsbasen_api/resource.rb
|
27
29
|
- lib/synsbasen_api/resources/brand.rb
|
28
30
|
- lib/synsbasen_api/resources/inspection.rb
|
29
31
|
- lib/synsbasen_api/resources/inspection_test_center.rb
|
32
|
+
- lib/synsbasen_api/resources/leasing_period.rb
|
30
33
|
- lib/synsbasen_api/resources/model.rb
|
31
34
|
- lib/synsbasen_api/resources/test_center.rb
|
32
35
|
- lib/synsbasen_api/resources/variant.rb
|
33
36
|
- lib/synsbasen_api/resources/vehicle.rb
|
34
37
|
- lib/synsbasen_api/resources/version.rb
|
38
|
+
- lib/synsbasen_api/searchable.rb
|
35
39
|
- lib/synsbasen_api/version.rb
|
36
40
|
homepage: https://github.com/Synsbasen/synsbasen-api-ruby
|
37
41
|
licenses:
|