synsbasen_api 1.0.2 → 1.0.4

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: 99ac1f53e97c96f3f21e0ad5b3144df4c2afbaaee5b8af8a42e04e24d23e6b8c
4
+ data.tar.gz: 6196d8929394e6b7a6271783ac34811f643a825c9db5852ef43fbba657ca6c70
5
5
  SHA512:
6
- metadata.gz: b391699f2a176d389d299f42f2bc440795e0b7cc64991979ee70747196b3d54c0104c8e2716dbfb35fed85e7c89fd00dd7561b1121f3db2499ac5a3b0e39b009
7
- data.tar.gz: e57c951a46a4718d7d5474ae6483ea272f3708f0e4d75670ff4844529b28ead5c45d721d77442f2414ad2a0c98c15189195424959b3fa3737c47309749a32319
6
+ metadata.gz: 8add0e93e0efe3572e05d2704f90b5b45ae4b55091f5b609a9851fcb5645b4c20916691cf81e82d64b110dbfc5789e1b40d763044ff056a1774543ed1db5041e
7
+ data.tar.gz: 0405b1d7b20293f55251956d6e70af0ef6450709c086c1e20b6dfdc9cea4ff107354b9a0967cf6dc18b9efab981e239cd8be3ab7408a1db33c654879ce5b5aa8
@@ -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
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'cgi/escape'
4
+
3
5
  module SynsbasenApi
4
6
  # The `Vehicle` class provides methods for interacting with vehicle-related
5
7
  # endpoints in the Synsbasen API. It extends the `Client` class.
@@ -10,8 +12,8 @@ module SynsbasenApi
10
12
  # @param id [String] The unique identifier of the vehicle.
11
13
  # @return [ApiResponse] An instance of `ApiResponse` containing details
12
14
  # of the specified vehicle.
13
- def find(id)
14
- get("/v1/vehicles/#{id}")
15
+ def find(id, expand: [])
16
+ get("/v1/vehicles/#{id}", expand: expand)
15
17
  end
16
18
 
17
19
  # Retrieves information about a vehicle based on its registration number.
@@ -19,8 +21,18 @@ module SynsbasenApi
19
21
  # @param registration [String] The registration number of the vehicle.
20
22
  # @return [ApiResponse] An instance of `ApiResponse` containing details
21
23
  # of the specified vehicle.
22
- def find_by_registration(registration)
23
- get("/v1/vehicles/registration/#{registration}")
24
+ def find_by_registration(registration, expand: [])
25
+ escaped_registration = CGI.escape(registration)
26
+ get("/v1/vehicles/registration/#{escaped_registration}", expand: expand)
27
+ end
28
+
29
+ # Retrieves information about a vehicle based on its VIN (Vehicle Identification Number).
30
+ #
31
+ # @param vin [String] The VIN of the vehicle.
32
+ # @return [ApiResponse] An instance of `ApiResponse` containing details
33
+ # of the specified vehicle.
34
+ def find_by_vin(vin, expand: [])
35
+ get("/v1/vehicles/vin/#{vin}", expand: expand)
24
36
  end
25
37
 
26
38
  # Performs a search for vehicles based on the provided criteria.
@@ -28,12 +40,13 @@ module SynsbasenApi
28
40
  # @param args [Hash] Additional parameters to customize the search.
29
41
  # @option args [String] :method The search method. Default is 'SELECT'.
30
42
  # @return [ApiResponse] An instance of `ApiResponse` containing search results.
31
- def search(args = {})
43
+ def search(args = {}, expand: nil)
32
44
  post(
33
45
  "/v1/vehicles/search",
34
46
  body: {
35
47
  method: 'SELECT',
36
- }.merge(args).to_json
48
+ }.merge(args),
49
+ expand: expand
37
50
  )
38
51
  end
39
52
  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.4"
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.4
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: 2024-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport