synsbasen_api 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f85e79d11e95b288b1fe48c55abe5c18771ef0e9250f6d3d0b04a2ee625d5a0
4
- data.tar.gz: '08630fa642993044cccaa788ff61dd90f45e99162b85619284c612cfec3a9803'
3
+ metadata.gz: 2d13815e17928657fa26ebc1d124b909410034c2713e61f48ddb730ca255e137
4
+ data.tar.gz: 58476734c861a468c7ad7aab2a87cf5815c5420c70176babec6614b88666fe28
5
5
  SHA512:
6
- metadata.gz: b391699f2a176d389d299f42f2bc440795e0b7cc64991979ee70747196b3d54c0104c8e2716dbfb35fed85e7c89fd00dd7561b1121f3db2499ac5a3b0e39b009
7
- data.tar.gz: e57c951a46a4718d7d5474ae6483ea272f3708f0e4d75670ff4844529b28ead5c45d721d77442f2414ad2a0c98c15189195424959b3fa3737c47309749a32319
6
+ metadata.gz: a5e5d967bcc260fa27c79c1887ae250d22c88dcd1a8578266fb4340060e3225cb74a3879c93e50ad2cbc8ce9fd25d2aae06c5068bf28ea5216a9bd68cb671ee6
7
+ data.tar.gz: 278e5e5cdf251caf9b64fdb134cc0d961b620cb11f7b5b393704ad32e04ddac63404bd3ab88ad458a032ba7667f3e138890ce729bb2912d77fbbe9de784ea391
@@ -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,10 +33,9 @@ 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: {}, body: {})
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
 
40
41
  handle_after_request_callback(response)
@@ -51,10 +52,10 @@ module SynsbasenApi
51
52
  # @param body [Hash] Request body.
52
53
  # @return [ApiResponse] An instance of `ApiResponse` containing the API response.
53
54
  # @raise [ClientError, ServerError] Raised for client or server errors.
54
- def post(path, params: {}, body: {})
55
+ def post(path, params: {}, body: {}, expand: [])
55
56
  response = connection.post(path) do |req|
56
57
  req.params = params
57
- req.body = body
58
+ req.body = { **body, expand: expand }.compact_blank.to_json
58
59
  end
59
60
 
60
61
  handle_after_request_callback(response)
@@ -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).to_json
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).to_json
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
@@ -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.2"
5
+ VERSION = "1.0.3"
6
6
  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.2
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-13 00:00:00.000000000 Z
12
+ date: 2023-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport