ev-recharge-sdk 1.0.0 → 1.1.0
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/README.md +38 -21
- data/lib/shell_ev/client.rb +8 -8
- data/lib/shell_ev/configuration.rb +13 -17
- data/lib/shell_ev/controllers/base_controller.rb +9 -9
- data/lib/shell_ev/controllers/charging_controller.rb +121 -154
- data/lib/shell_ev/controllers/locations_controller.rb +226 -142
- data/lib/shell_ev/controllers/o_auth_authorization_controller.rb +8 -8
- data/lib/shell_ev/exceptions/bad_request_exception.rb +33 -18
- data/lib/shell_ev/exceptions/{m405_error_response_error1_exception.rb → internal_server_error_exception.rb} +31 -26
- data/lib/shell_ev/exceptions/not_found_exception.rb +36 -19
- data/lib/shell_ev/exceptions/o_auth_provider_exception.rb +15 -15
- data/lib/shell_ev/exceptions/{m400_error_response_error1_exception.rb → serviceunavailable_exception.rb} +28 -28
- data/lib/shell_ev/exceptions/{m401_error_response_error1_exception.rb → too_many_requests_exception.rb} +28 -28
- data/lib/shell_ev/exceptions/unauthorized_exception.rb +32 -18
- data/lib/shell_ev/http/auth/o_auth2.rb +54 -10
- data/lib/shell_ev/models/accessibility.rb +1 -2
- data/lib/shell_ev/models/active_response200_json.rb +11 -13
- data/lib/shell_ev/models/address.rb +1 -3
- data/lib/shell_ev/models/bad_request_err_msg.rb +82 -0
- data/lib/shell_ev/models/{stop_charge_session_request_body_json.rb → charge_error.rb} +21 -10
- data/lib/shell_ev/models/charge_retrieve_state.rb +63 -0
- data/lib/shell_ev/models/chargesession_start_body.rb +7 -9
- data/lib/shell_ev/models/connector_vo.rb +4 -9
- data/lib/shell_ev/models/coordinates.rb +1 -2
- data/lib/shell_ev/models/data_active.rb +27 -45
- data/lib/shell_ev/models/data_retrieve.rb +31 -49
- data/lib/shell_ev/models/electrical_properties.rb +1 -3
- data/lib/shell_ev/models/evse_vo.rb +3 -8
- data/lib/shell_ev/models/get_charge_session_retrieve_response200_json.rb +11 -13
- data/lib/shell_ev/models/{get_markers_list_authorization_methods_enum.rb → get_ev_locations_authorization_methods_enum.rb} +4 -4
- data/lib/shell_ev/models/{get_markers_list_connector_types_enum.rb → get_ev_locations_connector_types_enum.rb} +4 -4
- data/lib/shell_ev/models/{get_markers_list_evse_status_enum.rb → get_ev_locations_evse_status_enum.rb} +4 -4
- data/lib/shell_ev/models/inline_response202.rb +9 -11
- data/lib/shell_ev/models/inline_response2021.rb +5 -6
- data/lib/shell_ev/models/inline_response202_data.rb +7 -5
- data/lib/shell_ev/models/internal_error_object.rb +70 -0
- data/lib/shell_ev/models/location_respone_object.rb +4 -11
- data/lib/shell_ev/models/{get_locations_list_authorization_methods_enum.rb → locations_markers_authorization_methods_enum.rb} +4 -4
- data/lib/shell_ev/models/{get_locations_list_connector_types_enum.rb → locations_markers_connector_types_enum.rb} +4 -4
- data/lib/shell_ev/models/{get_locations_list_evse_status_enum.rb → locations_markers_evse_status_enum.rb} +4 -4
- data/lib/shell_ev/models/multi_location_marker.rb +2 -6
- data/lib/shell_ev/models/{get_nearby_locations_authorization_methods_enum.rb → nearby_locations_authorization_methods_enum.rb} +4 -4
- data/lib/shell_ev/models/{get_nearby_locations_connector_types_enum.rb → nearby_locations_connector_types_enum.rb} +4 -4
- data/lib/shell_ev/models/{get_nearby_locations_evse_status_enum.rb → nearby_locations_evse_status_enum.rb} +4 -4
- data/lib/shell_ev/models/not_found_err_msg.rb +82 -0
- data/lib/shell_ev/models/o_auth_token.rb +2 -6
- data/lib/shell_ev/models/opening_hours_object.rb +1 -3
- data/lib/shell_ev/models/ratelimit_err_msg.rb +82 -0
- data/lib/shell_ev/models/response.rb +78 -0
- data/lib/shell_ev/models/serviceunavailable_err_msg.rb +82 -0
- data/lib/shell_ev/models/single_location_marker.rb +5 -11
- data/lib/shell_ev/models/single_location_marker_authorization_methods_items_enum.rb +1 -1
- data/lib/shell_ev/models/single_location_marker_response.rb +81 -0
- data/lib/shell_ev/models/tariff_vo.rb +3 -7
- data/lib/shell_ev/models/unauthorized_err_msg.rb +82 -0
- data/lib/shell_ev/utilities/file_wrapper.rb +9 -9
- data/lib/shell_ev/utilities/union_type_lookup.rb +3 -2
- data/lib/shell_ev.rb +40 -60
- data/test/controllers/controller_test_base.rb +0 -5
- data/test/controllers/test_charging_controller.rb +74 -17
- data/test/controllers/test_locations_controller.rb +65 -0
- metadata +31 -49
- data/lib/shell_ev/exceptions/http401_error_response_exception.rb +0 -52
- data/lib/shell_ev/exceptions/m404_error_response_error1_exception.rb +0 -53
- data/lib/shell_ev/exceptions/m429_error_response_error1_exception.rb +0 -52
- data/lib/shell_ev/exceptions/m500_error_response_error1_exception.rb +0 -52
- data/lib/shell_ev/exceptions/m503_error_response_error1_exception.rb +0 -52
- data/lib/shell_ev/models/data_active_session_code_enum.rb +0 -44
- data/lib/shell_ev/models/data_active_session_state_enum.rb +0 -35
- data/lib/shell_ev/models/data_retrieve_session_code_enum.rb +0 -44
- data/lib/shell_ev/models/data_retrieve_session_state_enum.rb +0 -35
- data/lib/shell_ev/models/env_enum.rb +0 -23
- data/lib/shell_ev/models/m400_error_response.rb +0 -78
- data/lib/shell_ev/models/m400_error_response_error.rb +0 -80
- data/lib/shell_ev/models/m401_error_response.rb +0 -78
- data/lib/shell_ev/models/m401_error_response_error.rb +0 -80
- data/lib/shell_ev/models/m404_error_response.rb +0 -79
- data/lib/shell_ev/models/m404_error_response_error.rb +0 -80
- data/lib/shell_ev/models/m405_error_response.rb +0 -78
- data/lib/shell_ev/models/m405_error_response_error.rb +0 -80
- data/lib/shell_ev/models/m429_error_response.rb +0 -78
- data/lib/shell_ev/models/m429_error_response_error.rb +0 -80
- data/lib/shell_ev/models/m500_error_response.rb +0 -78
- data/lib/shell_ev/models/m500_error_response_error.rb +0 -80
- data/lib/shell_ev/models/m503_error_response.rb +0 -78
- data/lib/shell_ev/models/m503_error_response_error.rb +0 -80
- data/lib/shell_ev/models/response_base_status_enum.rb +0 -26
- data/lib/shell_ev/models/response_error401_all_of1.rb +0 -57
- data/lib/shell_ev/models/response_error401_all_of1_errors_items.rb +0 -80
- data/lib/shell_ev/models/success_response.rb +0 -58
@@ -4,49 +4,54 @@
|
|
4
4
|
# ( https://apimatic.io ).
|
5
5
|
|
6
6
|
module ShellEv
|
7
|
-
#
|
8
|
-
class
|
7
|
+
# InternalServerError class.
|
8
|
+
class InternalServerErrorException < APIException
|
9
9
|
SKIP = Object.new
|
10
10
|
private_constant :SKIP
|
11
11
|
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# requestId is unique identifier value that is attached to requests and
|
13
|
+
# messages that allow reference to a particular transaction or event chain.
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :request_id
|
16
16
|
|
17
|
-
#
|
17
|
+
# Status of the request
|
18
18
|
# @return [String]
|
19
19
|
attr_accessor :status
|
20
20
|
|
21
|
-
#
|
22
|
-
# @return [Array[
|
21
|
+
# Exception details of the error
|
22
|
+
# @return [Array[InternalErrorObject]]
|
23
23
|
attr_accessor :errors
|
24
24
|
|
25
|
-
#
|
26
|
-
# @
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
25
|
+
# Exception details of the error
|
26
|
+
# @return [Array[String]]
|
27
|
+
attr_accessor :details
|
28
|
+
|
29
|
+
# The constructor.
|
30
|
+
# @param [String] The reason for raising an exception.
|
31
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
32
|
+
def initialize(reason, response)
|
33
|
+
super(reason, response)
|
34
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
35
|
+
unbox(hash)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Populates this object by extracting properties from a hash.
|
39
|
+
# @param [Hash] The deserialized response sent by the server in the
|
40
|
+
# response body.
|
41
|
+
def unbox(hash)
|
42
|
+
@request_id = hash.key?('requestId') ? hash['requestId'] : SKIP
|
43
|
+
@status = hash.key?('status') ? hash['status'] : SKIP
|
40
44
|
# Parameter is an array, so we need to iterate through it
|
41
45
|
@errors = nil
|
42
|
-
unless hash['
|
46
|
+
unless hash['errors'].nil?
|
43
47
|
@errors = []
|
44
|
-
hash['
|
45
|
-
@errors << (
|
48
|
+
hash['errors'].each do |structure|
|
49
|
+
@errors << (InternalErrorObject.from_hash(structure) if structure)
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
49
|
-
@errors = SKIP unless hash.key?('
|
53
|
+
@errors = SKIP unless hash.key?('errors')
|
54
|
+
@details = hash.key?('details') ? hash['details'] : SKIP
|
50
55
|
end
|
51
56
|
end
|
52
57
|
end
|
@@ -4,34 +4,51 @@
|
|
4
4
|
# ( https://apimatic.io ).
|
5
5
|
|
6
6
|
module ShellEv
|
7
|
-
#
|
7
|
+
# Requested resource path not available it will provides the error in OpenAPI
|
8
|
+
# spec mentioned format, if there is any change in base URL then respective
|
9
|
+
# platform error message will be populated.
|
8
10
|
class NotFoundException < APIException
|
9
11
|
SKIP = Object.new
|
10
12
|
private_constant :SKIP
|
11
13
|
|
12
|
-
#
|
14
|
+
# requestId is unique identifier value that is attached to requests and
|
15
|
+
# messages that allow reference to a particular transaction or event chain.
|
13
16
|
# @return [String]
|
14
|
-
attr_accessor :
|
17
|
+
attr_accessor :request_id
|
15
18
|
|
16
|
-
#
|
19
|
+
# Status of the request
|
17
20
|
# @return [String]
|
18
|
-
attr_accessor :
|
21
|
+
attr_accessor :status
|
19
22
|
|
20
|
-
#
|
21
|
-
# @
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
# Exception details of the error
|
24
|
+
# @return [Array[NotFoundErrMsg]]
|
25
|
+
attr_accessor :errors
|
26
|
+
|
27
|
+
# The constructor.
|
28
|
+
# @param [String] The reason for raising an exception.
|
29
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
30
|
+
def initialize(reason, response)
|
31
|
+
super(reason, response)
|
32
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
33
|
+
unbox(hash)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Populates this object by extracting properties from a hash.
|
37
|
+
# @param [Hash] The deserialized response sent by the server in the
|
38
|
+
# response body.
|
39
|
+
def unbox(hash)
|
40
|
+
@request_id = hash.key?('requestId') ? hash['requestId'] : SKIP
|
41
|
+
@status = hash.key?('status') ? hash['status'] : SKIP
|
42
|
+
# Parameter is an array, so we need to iterate through it
|
43
|
+
@errors = nil
|
44
|
+
unless hash['errors'].nil?
|
45
|
+
@errors = []
|
46
|
+
hash['errors'].each do |structure|
|
47
|
+
@errors << (NotFoundErrMsg.from_hash(structure) if structure)
|
48
|
+
end
|
49
|
+
end
|
28
50
|
|
29
|
-
|
30
|
-
# @param [Hash] The deserialized response sent by the server in the
|
31
|
-
# response body.
|
32
|
-
def unbox(hash)
|
33
|
-
@code = hash.key?('code') ? hash['code'] : SKIP
|
34
|
-
@message = hash.key?('message') ? hash['message'] : SKIP
|
51
|
+
@errors = SKIP unless hash.key?('errors')
|
35
52
|
end
|
36
53
|
end
|
37
54
|
end
|
@@ -24,21 +24,21 @@ module ShellEv
|
|
24
24
|
# about the error, used to provide the client developer with additional
|
25
25
|
# information about the error.
|
26
26
|
# @return [String]
|
27
|
-
attr_accessor :error_uri
|
28
|
-
|
29
|
-
# The constructor.
|
30
|
-
# @param [String] The reason for raising an exception.
|
31
|
-
# @param [HttpResponse] The HttpReponse of the API call.
|
32
|
-
def initialize(reason, response)
|
33
|
-
super(reason, response)
|
34
|
-
hash = APIHelper.json_deserialize(@response.raw_body)
|
35
|
-
unbox(hash)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Populates this object by extracting properties from a hash.
|
39
|
-
# @param [Hash] The deserialized response sent by the server in the
|
40
|
-
# response body.
|
41
|
-
def unbox(hash)
|
27
|
+
attr_accessor :error_uri
|
28
|
+
|
29
|
+
# The constructor.
|
30
|
+
# @param [String] The reason for raising an exception.
|
31
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
32
|
+
def initialize(reason, response)
|
33
|
+
super(reason, response)
|
34
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
35
|
+
unbox(hash)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Populates this object by extracting properties from a hash.
|
39
|
+
# @param [Hash] The deserialized response sent by the server in the
|
40
|
+
# response body.
|
41
|
+
def unbox(hash)
|
42
42
|
@error = hash.key?('error') ? hash['error'] : nil
|
43
43
|
@error_description =
|
44
44
|
hash.key?('error_description') ? hash['error_description'] : SKIP
|
@@ -4,49 +4,49 @@
|
|
4
4
|
# ( https://apimatic.io ).
|
5
5
|
|
6
6
|
module ShellEv
|
7
|
-
#
|
8
|
-
class
|
7
|
+
# Serviceunavailable class.
|
8
|
+
class ServiceunavailableException < APIException
|
9
9
|
SKIP = Object.new
|
10
10
|
private_constant :SKIP
|
11
11
|
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# requestId is unique identifier value that is attached to requests and
|
13
|
+
# messages that allow reference to a particular transaction or event chain.
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :request_id
|
16
16
|
|
17
|
-
#
|
17
|
+
# Status of the request
|
18
18
|
# @return [String]
|
19
19
|
attr_accessor :status
|
20
20
|
|
21
|
-
#
|
22
|
-
# @return [Array[
|
23
|
-
attr_accessor :errors
|
24
|
-
|
25
|
-
# The constructor.
|
26
|
-
# @param [String] The reason for raising an exception.
|
27
|
-
# @param [HttpResponse] The HttpReponse of the API call.
|
28
|
-
def initialize(reason, response)
|
29
|
-
super(reason, response)
|
30
|
-
hash = APIHelper.json_deserialize(@response.raw_body)
|
31
|
-
unbox(hash)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Populates this object by extracting properties from a hash.
|
35
|
-
# @param [Hash] The deserialized response sent by the server in the
|
36
|
-
# response body.
|
37
|
-
def unbox(hash)
|
38
|
-
@request_id = hash.key?('
|
39
|
-
@status = hash.key?('
|
21
|
+
# Exception details of the error
|
22
|
+
# @return [Array[ServiceunavailableErrMsg]]
|
23
|
+
attr_accessor :errors
|
24
|
+
|
25
|
+
# The constructor.
|
26
|
+
# @param [String] The reason for raising an exception.
|
27
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
28
|
+
def initialize(reason, response)
|
29
|
+
super(reason, response)
|
30
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
31
|
+
unbox(hash)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Populates this object by extracting properties from a hash.
|
35
|
+
# @param [Hash] The deserialized response sent by the server in the
|
36
|
+
# response body.
|
37
|
+
def unbox(hash)
|
38
|
+
@request_id = hash.key?('requestId') ? hash['requestId'] : SKIP
|
39
|
+
@status = hash.key?('status') ? hash['status'] : SKIP
|
40
40
|
# Parameter is an array, so we need to iterate through it
|
41
41
|
@errors = nil
|
42
|
-
unless hash['
|
42
|
+
unless hash['errors'].nil?
|
43
43
|
@errors = []
|
44
|
-
hash['
|
45
|
-
@errors << (
|
44
|
+
hash['errors'].each do |structure|
|
45
|
+
@errors << (ServiceunavailableErrMsg.from_hash(structure) if structure)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
@errors = SKIP unless hash.key?('
|
49
|
+
@errors = SKIP unless hash.key?('errors')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -4,49 +4,49 @@
|
|
4
4
|
# ( https://apimatic.io ).
|
5
5
|
|
6
6
|
module ShellEv
|
7
|
-
#
|
8
|
-
class
|
7
|
+
# TooManyRequests class.
|
8
|
+
class TooManyRequestsException < APIException
|
9
9
|
SKIP = Object.new
|
10
10
|
private_constant :SKIP
|
11
11
|
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# RequestID is unique identifier value that is attached to requests and
|
13
|
+
# messages that allow reference to a particular transaction or event chain.
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :request_id
|
16
16
|
|
17
|
-
#
|
17
|
+
# Status of the request
|
18
18
|
# @return [String]
|
19
19
|
attr_accessor :status
|
20
20
|
|
21
|
-
#
|
22
|
-
# @return [Array[
|
23
|
-
attr_accessor :errors
|
24
|
-
|
25
|
-
# The constructor.
|
26
|
-
# @param [String] The reason for raising an exception.
|
27
|
-
# @param [HttpResponse] The HttpReponse of the API call.
|
28
|
-
def initialize(reason, response)
|
29
|
-
super(reason, response)
|
30
|
-
hash = APIHelper.json_deserialize(@response.raw_body)
|
31
|
-
unbox(hash)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Populates this object by extracting properties from a hash.
|
35
|
-
# @param [Hash] The deserialized response sent by the server in the
|
36
|
-
# response body.
|
37
|
-
def unbox(hash)
|
38
|
-
@request_id = hash.key?('
|
39
|
-
@status = hash.key?('
|
21
|
+
# Exception details of the error
|
22
|
+
# @return [Array[RatelimitErrMsg]]
|
23
|
+
attr_accessor :errors
|
24
|
+
|
25
|
+
# The constructor.
|
26
|
+
# @param [String] The reason for raising an exception.
|
27
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
28
|
+
def initialize(reason, response)
|
29
|
+
super(reason, response)
|
30
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
31
|
+
unbox(hash)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Populates this object by extracting properties from a hash.
|
35
|
+
# @param [Hash] The deserialized response sent by the server in the
|
36
|
+
# response body.
|
37
|
+
def unbox(hash)
|
38
|
+
@request_id = hash.key?('requestId') ? hash['requestId'] : SKIP
|
39
|
+
@status = hash.key?('status') ? hash['status'] : SKIP
|
40
40
|
# Parameter is an array, so we need to iterate through it
|
41
41
|
@errors = nil
|
42
|
-
unless hash['
|
42
|
+
unless hash['errors'].nil?
|
43
43
|
@errors = []
|
44
|
-
hash['
|
45
|
-
@errors << (
|
44
|
+
hash['errors'].each do |structure|
|
45
|
+
@errors << (RatelimitErrMsg.from_hash(structure) if structure)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
@errors = SKIP unless hash.key?('
|
49
|
+
@errors = SKIP unless hash.key?('errors')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -9,29 +9,43 @@ module ShellEv
|
|
9
9
|
SKIP = Object.new
|
10
10
|
private_constant :SKIP
|
11
11
|
|
12
|
-
#
|
12
|
+
# requestId or correlation id of the message
|
13
13
|
# @return [String]
|
14
|
-
attr_accessor :
|
14
|
+
attr_accessor :request_id
|
15
15
|
|
16
|
-
#
|
16
|
+
# Status of the request
|
17
17
|
# @return [String]
|
18
|
-
attr_accessor :
|
18
|
+
attr_accessor :status
|
19
19
|
|
20
|
-
#
|
21
|
-
# @
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
# Exception details of the error
|
21
|
+
# @return [Array[UnauthorizedErrMsg]]
|
22
|
+
attr_accessor :errors
|
23
|
+
|
24
|
+
# The constructor.
|
25
|
+
# @param [String] The reason for raising an exception.
|
26
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
27
|
+
def initialize(reason, response)
|
28
|
+
super(reason, response)
|
29
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
30
|
+
unbox(hash)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Populates this object by extracting properties from a hash.
|
34
|
+
# @param [Hash] The deserialized response sent by the server in the
|
35
|
+
# response body.
|
36
|
+
def unbox(hash)
|
37
|
+
@request_id = hash.key?('requestId') ? hash['requestId'] : SKIP
|
38
|
+
@status = hash.key?('status') ? hash['status'] : SKIP
|
39
|
+
# Parameter is an array, so we need to iterate through it
|
40
|
+
@errors = nil
|
41
|
+
unless hash['errors'].nil?
|
42
|
+
@errors = []
|
43
|
+
hash['errors'].each do |structure|
|
44
|
+
@errors << (UnauthorizedErrMsg.from_hash(structure) if structure)
|
45
|
+
end
|
46
|
+
end
|
28
47
|
|
29
|
-
|
30
|
-
# @param [Hash] The deserialized response sent by the server in the
|
31
|
-
# response body.
|
32
|
-
def unbox(hash)
|
33
|
-
@code = hash.key?('code') ? hash['code'] : SKIP
|
34
|
-
@message = hash.key?('message') ? hash['message'] : SKIP
|
48
|
+
@errors = SKIP unless hash.key?('errors')
|
35
49
|
end
|
36
50
|
end
|
37
51
|
end
|
@@ -15,23 +15,27 @@ module ShellEv
|
|
15
15
|
|
16
16
|
# Initialization constructor.
|
17
17
|
def initialize(client_credentials_auth_credentials, config)
|
18
|
-
auth_params = {}
|
19
18
|
@_o_auth_client_id = client_credentials_auth_credentials.o_auth_client_id unless
|
20
19
|
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_client_id.nil?
|
21
20
|
@_o_auth_client_secret = client_credentials_auth_credentials.o_auth_client_secret unless
|
22
21
|
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_client_secret.nil?
|
23
22
|
@_o_auth_token = client_credentials_auth_credentials.o_auth_token unless
|
24
23
|
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_token.nil?
|
24
|
+
@_o_auth_clock_skew = client_credentials_auth_credentials.o_auth_clock_skew unless
|
25
|
+
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_clock_skew.nil?
|
26
|
+
@_o_auth_token_provider = client_credentials_auth_credentials.o_auth_token_provider unless
|
27
|
+
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_token_provider.nil?
|
28
|
+
@_o_auth_on_token_update = client_credentials_auth_credentials.o_auth_on_token_update unless
|
29
|
+
client_credentials_auth_credentials.nil? || client_credentials_auth_credentials.o_auth_on_token_update.nil?
|
25
30
|
@_o_auth_api = OAuthAuthorizationController.new(config)
|
26
|
-
|
27
|
-
|
28
|
-
super auth_params
|
31
|
+
super({})
|
29
32
|
end
|
30
33
|
|
31
34
|
# Validates the oAuth token.
|
32
35
|
# @return [Boolean] true if the token is present and not expired.
|
33
36
|
def valid
|
34
|
-
|
37
|
+
@_o_auth_token = get_token_from_provider
|
38
|
+
@_o_auth_token.is_a?(OAuthToken) && !token_expired?(@_o_auth_token)
|
35
39
|
end
|
36
40
|
|
37
41
|
# Builds the basic auth header for endpoints in the OAuth Authorization Controller.
|
@@ -58,32 +62,72 @@ module ShellEv
|
|
58
62
|
# @param [OAuthToken] token The oAuth token instance.
|
59
63
|
# @return [Boolean] true if the token's expiry exist and also the token is expired, false otherwise.
|
60
64
|
def token_expired?(token)
|
61
|
-
token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry)
|
65
|
+
token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry, @_o_auth_clock_skew)
|
66
|
+
end
|
67
|
+
|
68
|
+
def apply(http_request)
|
69
|
+
auth_params = { 'Authorization' => "Bearer #{@_o_auth_token.access_token}" }
|
70
|
+
AuthHelper.apply(auth_params, http_request.method(:add_header))
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
# This provides the OAuth Token from either the user configured callbacks or from default provider.
|
76
|
+
# @return [OAuthToken] The fetched oauth token.
|
77
|
+
def get_token_from_provider
|
78
|
+
return @_o_auth_token if @_o_auth_token && !token_expired?(@_o_auth_token)
|
79
|
+
|
80
|
+
if @_o_auth_token_provider
|
81
|
+
o_auth_token = @_o_auth_token_provider.call(@_o_auth_token, self)
|
82
|
+
@_o_auth_on_token_update&.call(o_auth_token)
|
83
|
+
return o_auth_token
|
84
|
+
end
|
85
|
+
begin
|
86
|
+
o_auth_token = fetch_token
|
87
|
+
@_o_auth_on_token_update&.call(o_auth_token)
|
88
|
+
o_auth_token
|
89
|
+
rescue ApiException
|
90
|
+
@_o_auth_token
|
91
|
+
end
|
62
92
|
end
|
63
93
|
end
|
64
94
|
|
65
95
|
# Data class for ClientCredentialsAuthCredentials.
|
66
96
|
class ClientCredentialsAuthCredentials
|
67
|
-
attr_reader :o_auth_client_id, :o_auth_client_secret, :o_auth_token
|
97
|
+
attr_reader :o_auth_client_id, :o_auth_client_secret, :o_auth_token,
|
98
|
+
:o_auth_token_provider, :o_auth_on_token_update,
|
99
|
+
:o_auth_clock_skew
|
68
100
|
|
69
|
-
def initialize(o_auth_client_id:, o_auth_client_secret:, o_auth_token: nil
|
101
|
+
def initialize(o_auth_client_id:, o_auth_client_secret:, o_auth_token: nil,
|
102
|
+
o_auth_token_provider: nil, o_auth_on_token_update: nil,
|
103
|
+
o_auth_clock_skew: nil)
|
70
104
|
raise ArgumentError, 'o_auth_client_id cannot be nil' if o_auth_client_id.nil?
|
71
105
|
raise ArgumentError, 'o_auth_client_secret cannot be nil' if o_auth_client_secret.nil?
|
72
106
|
|
73
107
|
@o_auth_client_id = o_auth_client_id
|
74
108
|
@o_auth_client_secret = o_auth_client_secret
|
75
109
|
@o_auth_token = o_auth_token
|
110
|
+
@o_auth_token_provider = o_auth_token_provider
|
111
|
+
@o_auth_on_token_update = o_auth_on_token_update
|
112
|
+
@o_auth_clock_skew = o_auth_clock_skew
|
76
113
|
end
|
77
114
|
|
78
115
|
def clone_with(o_auth_client_id: nil, o_auth_client_secret: nil,
|
79
|
-
o_auth_token: nil
|
116
|
+
o_auth_token: nil, o_auth_token_provider: nil,
|
117
|
+
o_auth_on_token_update: nil, o_auth_clock_skew: nil)
|
80
118
|
o_auth_client_id ||= self.o_auth_client_id
|
81
119
|
o_auth_client_secret ||= self.o_auth_client_secret
|
82
120
|
o_auth_token ||= self.o_auth_token
|
121
|
+
o_auth_token_provider ||= self.o_auth_token_provider
|
122
|
+
o_auth_on_token_update ||= self.o_auth_on_token_update
|
123
|
+
o_auth_clock_skew ||= self.o_auth_clock_skew
|
83
124
|
|
84
125
|
ClientCredentialsAuthCredentials.new(
|
85
126
|
o_auth_client_id: o_auth_client_id,
|
86
|
-
o_auth_client_secret: o_auth_client_secret, o_auth_token: o_auth_token
|
127
|
+
o_auth_client_secret: o_auth_client_secret, o_auth_token: o_auth_token,
|
128
|
+
o_auth_token_provider: o_auth_token_provider,
|
129
|
+
o_auth_on_token_update: o_auth_on_token_update,
|
130
|
+
o_auth_clock_skew: o_auth_clock_skew
|
87
131
|
)
|
88
132
|
end
|
89
133
|
end
|
@@ -9,8 +9,8 @@ module ShellEv
|
|
9
9
|
SKIP = Object.new
|
10
10
|
private_constant :SKIP
|
11
11
|
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# Mandatory UUID (according to RFC 4122 standards) for requests and
|
13
|
+
# responses. This will be played back in the response from the request.
|
14
14
|
# @return [UUID | String]
|
15
15
|
attr_accessor :request_id
|
16
16
|
|
@@ -25,9 +25,9 @@ module ShellEv
|
|
25
25
|
# A mapping from model property names to API property names.
|
26
26
|
def self.names
|
27
27
|
@_hash = {} if @_hash.nil?
|
28
|
-
@_hash['request_id'] = '
|
29
|
-
@_hash['status'] = '
|
30
|
-
@_hash['data'] = '
|
28
|
+
@_hash['request_id'] = 'requestId'
|
29
|
+
@_hash['status'] = 'status'
|
30
|
+
@_hash['data'] = 'data'
|
31
31
|
@_hash
|
32
32
|
end
|
33
33
|
|
@@ -43,9 +43,7 @@ module ShellEv
|
|
43
43
|
[]
|
44
44
|
end
|
45
45
|
|
46
|
-
def initialize(request_id = nil,
|
47
|
-
status = nil,
|
48
|
-
data = SKIP)
|
46
|
+
def initialize(request_id = nil, status = nil, data = SKIP)
|
49
47
|
@request_id = request_id
|
50
48
|
@status = status
|
51
49
|
@data = data unless data == SKIP
|
@@ -56,18 +54,18 @@ module ShellEv
|
|
56
54
|
return nil unless hash
|
57
55
|
|
58
56
|
# Extract variables from the hash.
|
59
|
-
request_id = hash.key?('
|
60
|
-
status = hash.key?('
|
57
|
+
request_id = hash.key?('requestId') ? hash['requestId'] : nil
|
58
|
+
status = hash.key?('status') ? hash['status'] : nil
|
61
59
|
# Parameter is an array, so we need to iterate through it
|
62
60
|
data = nil
|
63
|
-
unless hash['
|
61
|
+
unless hash['data'].nil?
|
64
62
|
data = []
|
65
|
-
hash['
|
63
|
+
hash['data'].each do |structure|
|
66
64
|
data << (DataActive.from_hash(structure) if structure)
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
70
|
-
data = SKIP unless hash.key?('
|
68
|
+
data = SKIP unless hash.key?('data')
|
71
69
|
|
72
70
|
# Create object from extracted values.
|
73
71
|
ActiveResponse200Json.new(request_id,
|
@@ -50,9 +50,7 @@ module ShellEv
|
|
50
50
|
[]
|
51
51
|
end
|
52
52
|
|
53
|
-
def initialize(street_and_number = SKIP,
|
54
|
-
postal_code = SKIP,
|
55
|
-
city = SKIP,
|
53
|
+
def initialize(street_and_number = SKIP, postal_code = SKIP, city = SKIP,
|
56
54
|
country = SKIP)
|
57
55
|
@street_and_number = street_and_number unless street_and_number == SKIP
|
58
56
|
@postal_code = postal_code unless postal_code == SKIP
|