synsbasen_api 1.0.1 → 1.0.3
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/client.rb +20 -5
- data/lib/synsbasen_api/resources/brand.rb +4 -4
- data/lib/synsbasen_api/resources/inspection.rb +3 -2
- data/lib/synsbasen_api/resources/model.rb +4 -4
- data/lib/synsbasen_api/resources/variant.rb +4 -4
- data/lib/synsbasen_api/resources/vehicle.rb +16 -6
- data/lib/synsbasen_api/resources/version.rb +4 -4
- data/lib/synsbasen_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d13815e17928657fa26ebc1d124b909410034c2713e61f48ddb730ca255e137
|
4
|
+
data.tar.gz: 58476734c861a468c7ad7aab2a87cf5815c5420c70176babec6614b88666fe28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5e5d967bcc260fa27c79c1887ae250d22c88dcd1a8578266fb4340060e3225cb74a3879c93e50ad2cbc8ce9fd25d2aae06c5068bf28ea5216a9bd68cb671ee6
|
7
|
+
data.tar.gz: 278e5e5cdf251caf9b64fdb134cc0d961b620cb11f7b5b393704ad32e04ddac63404bd3ab88ad458a032ba7667f3e138890ce729bb2912d77fbbe9de784ea391
|
data/lib/synsbasen_api/client.rb
CHANGED
@@ -4,6 +4,8 @@ require "synsbasen_api/api_response"
|
|
4
4
|
require "synsbasen_api/error"
|
5
5
|
require "faraday"
|
6
6
|
require "active_support/core_ext/hash/keys"
|
7
|
+
require "active_support/core_ext/object/blank"
|
8
|
+
require "active_support/core_ext/enumerable"
|
7
9
|
|
8
10
|
module SynsbasenApi
|
9
11
|
# The `Client` class serves as the base class for interacting with the Synsbasen API.
|
@@ -31,12 +33,13 @@ module SynsbasenApi
|
|
31
33
|
# @param body [Hash] Request body.
|
32
34
|
# @return [ApiResponse] An instance of `ApiResponse` containing the API response.
|
33
35
|
# @raise [ClientError, ServerError] Raised for client or server errors.
|
34
|
-
def get(path, params: {},
|
36
|
+
def get(path, params: {}, expand: [])
|
35
37
|
response = connection.get(path) do |req|
|
36
|
-
req.params = params
|
37
|
-
req.body = body unless body.empty?
|
38
|
+
req.params = { **params, expand: expand }.compact_blank
|
38
39
|
end
|
39
40
|
|
41
|
+
handle_after_request_callback(response)
|
42
|
+
|
40
43
|
ApiResponse.new(JSON.parse(response.body).deep_symbolize_keys)
|
41
44
|
rescue => e
|
42
45
|
rescue_and_raise_errors(e)
|
@@ -49,12 +52,14 @@ module SynsbasenApi
|
|
49
52
|
# @param body [Hash] Request body.
|
50
53
|
# @return [ApiResponse] An instance of `ApiResponse` containing the API response.
|
51
54
|
# @raise [ClientError, ServerError] Raised for client or server errors.
|
52
|
-
def post(path, params: {}, body: {})
|
55
|
+
def post(path, params: {}, body: {}, expand: [])
|
53
56
|
response = connection.post(path) do |req|
|
54
57
|
req.params = params
|
55
|
-
req.body = body
|
58
|
+
req.body = { **body, expand: expand }.compact_blank.to_json
|
56
59
|
end
|
57
60
|
|
61
|
+
handle_after_request_callback(response)
|
62
|
+
|
58
63
|
ApiResponse.new(JSON.parse(response.body).deep_symbolize_keys)
|
59
64
|
rescue => e
|
60
65
|
rescue_and_raise_errors(e)
|
@@ -78,6 +83,16 @@ module SynsbasenApi
|
|
78
83
|
raise e
|
79
84
|
end
|
80
85
|
end
|
86
|
+
|
87
|
+
# Calls the after_request callback if configured in the SynsbasenApi.
|
88
|
+
#
|
89
|
+
# @param response [Faraday::Response] The Faraday response object.
|
90
|
+
# @return [void]
|
91
|
+
def handle_after_request_callback(response)
|
92
|
+
return unless SynsbasenApi.config[:after_request]
|
93
|
+
|
94
|
+
SynsbasenApi.config[:after_request].call(response)
|
95
|
+
end
|
81
96
|
end
|
82
97
|
end
|
83
98
|
end
|
@@ -10,16 +10,16 @@ module SynsbasenApi
|
|
10
10
|
# @param id [String] The unique identifier of the brand.
|
11
11
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
12
12
|
# of the specified brand.
|
13
|
-
def find(id)
|
14
|
-
get("/v1/brands/#{id}")
|
13
|
+
def find(id, expand: [])
|
14
|
+
get("/v1/brands/#{id}", expand: expand)
|
15
15
|
end
|
16
16
|
|
17
17
|
# Retrieves information about all brands.
|
18
18
|
#
|
19
19
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
20
20
|
# of all brands.
|
21
|
-
def all
|
22
|
-
get("/v1/brands")
|
21
|
+
def all(expand: [])
|
22
|
+
get("/v1/brands", expand: expand)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -10,12 +10,13 @@ module SynsbasenApi
|
|
10
10
|
# @param args [Hash] Additional parameters to customize the search.
|
11
11
|
# @option args [String] :method The search method. Default is 'SELECT'.
|
12
12
|
# @return [ApiResponse] An instance of `ApiResponse` containing search results.
|
13
|
-
def search(args = {})
|
13
|
+
def search(args = {}, expand: [])
|
14
14
|
post(
|
15
15
|
"/v1/inspections/search",
|
16
16
|
body: {
|
17
17
|
method: 'SELECT',
|
18
|
-
}.merge(args)
|
18
|
+
}.merge(args),
|
19
|
+
expand: expand
|
19
20
|
)
|
20
21
|
end
|
21
22
|
end
|
@@ -10,8 +10,8 @@ module SynsbasenApi
|
|
10
10
|
# @param id [String] The unique identifier of the model.
|
11
11
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
12
12
|
# of the specified model.
|
13
|
-
def find(id)
|
14
|
-
get("/v1/models/#{id}")
|
13
|
+
def find(id, expand: [])
|
14
|
+
get("/v1/models/#{id}", expand: expand)
|
15
15
|
end
|
16
16
|
|
17
17
|
# Retrieves information about all models associated with a given brand.
|
@@ -19,8 +19,8 @@ module SynsbasenApi
|
|
19
19
|
# @param brand_id [String] The unique identifier of the brand.
|
20
20
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
21
21
|
# of all models associated with the specified brand.
|
22
|
-
def all(brand_id)
|
23
|
-
get("/v1/brands/#{brand_id}/models")
|
22
|
+
def all(brand_id, expand: [])
|
23
|
+
get("/v1/brands/#{brand_id}/models", expand: expand)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -10,8 +10,8 @@ module SynsbasenApi
|
|
10
10
|
# @param id [String] The unique identifier of the variant.
|
11
11
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
12
12
|
# of the specified variant.
|
13
|
-
def find(id)
|
14
|
-
get("/v1/variants/#{id}")
|
13
|
+
def find(id, expand: [])
|
14
|
+
get("/v1/variants/#{id}", expand: expand)
|
15
15
|
end
|
16
16
|
|
17
17
|
# Retrieves information about all variants associated with a given model.
|
@@ -19,8 +19,8 @@ module SynsbasenApi
|
|
19
19
|
# @param model_id [String] The unique identifier of the model.
|
20
20
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
21
21
|
# of all variants associated with the specified model.
|
22
|
-
def all(model_id)
|
23
|
-
get("/v1/models/#{model_id}/variants")
|
22
|
+
def all(model_id, expand: [])
|
23
|
+
get("/v1/models/#{model_id}/variants", expand: expand)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -10,8 +10,8 @@ module SynsbasenApi
|
|
10
10
|
# @param id [String] The unique identifier of the vehicle.
|
11
11
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
12
12
|
# of the specified vehicle.
|
13
|
-
def find(id)
|
14
|
-
get("/v1/vehicles/#{id}")
|
13
|
+
def find(id, expand: [])
|
14
|
+
get("/v1/vehicles/#{id}", expand: expand)
|
15
15
|
end
|
16
16
|
|
17
17
|
# Retrieves information about a vehicle based on its registration number.
|
@@ -19,8 +19,17 @@ module SynsbasenApi
|
|
19
19
|
# @param registration [String] The registration number of the vehicle.
|
20
20
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
21
21
|
# of the specified vehicle.
|
22
|
-
def find_by_registration(registration)
|
23
|
-
get("/v1/vehicles/registration/#{registration}")
|
22
|
+
def find_by_registration(registration, expand: [])
|
23
|
+
get("/v1/vehicles/registration/#{registration}", expand: expand)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Retrieves information about a vehicle based on its VIN (Vehicle Identification Number).
|
27
|
+
#
|
28
|
+
# @param vin [String] The VIN of the vehicle.
|
29
|
+
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
30
|
+
# of the specified vehicle.
|
31
|
+
def find_by_vin(vin, expand: [])
|
32
|
+
get("/v1/vehicles/vin/#{vin}", expand: expand)
|
24
33
|
end
|
25
34
|
|
26
35
|
# Performs a search for vehicles based on the provided criteria.
|
@@ -28,12 +37,13 @@ module SynsbasenApi
|
|
28
37
|
# @param args [Hash] Additional parameters to customize the search.
|
29
38
|
# @option args [String] :method The search method. Default is 'SELECT'.
|
30
39
|
# @return [ApiResponse] An instance of `ApiResponse` containing search results.
|
31
|
-
def search(args = {})
|
40
|
+
def search(args = {}, expand: nil)
|
32
41
|
post(
|
33
42
|
"/v1/vehicles/search",
|
34
43
|
body: {
|
35
44
|
method: 'SELECT',
|
36
|
-
}.merge(args)
|
45
|
+
}.merge(args),
|
46
|
+
expand: expand
|
37
47
|
)
|
38
48
|
end
|
39
49
|
end
|
@@ -10,8 +10,8 @@ module SynsbasenApi
|
|
10
10
|
# @param id [String] The unique identifier of the version.
|
11
11
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
12
12
|
# of the specified version.
|
13
|
-
def find(id)
|
14
|
-
get("/v1/versions/#{id}")
|
13
|
+
def find(id, expand: [])
|
14
|
+
get("/v1/versions/#{id}", expand: expand)
|
15
15
|
end
|
16
16
|
|
17
17
|
# Retrieves information about all versions associated with a given variant.
|
@@ -19,8 +19,8 @@ module SynsbasenApi
|
|
19
19
|
# @param variant_id [String] The unique identifier of the variant.
|
20
20
|
# @return [ApiResponse] An instance of `ApiResponse` containing details
|
21
21
|
# of all versions associated with the specified variant.
|
22
|
-
def all(variant_id)
|
23
|
-
get("/v1/variants/#{variant_id}/versions")
|
22
|
+
def all(variant_id, expand: [])
|
23
|
+
get("/v1/variants/#{variant_id}/versions", expand: expand)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
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.3
|
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: 2023-11-
|
12
|
+
date: 2023-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|