tesla-api-sdk 1.0.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.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +160 -0
  4. data/bin/console +15 -0
  5. data/lib/tesla_fleet_management_api/api_helper.rb +10 -0
  6. data/lib/tesla_fleet_management_api/client.rb +110 -0
  7. data/lib/tesla_fleet_management_api/configuration.rb +181 -0
  8. data/lib/tesla_fleet_management_api/controllers/base_controller.rb +65 -0
  9. data/lib/tesla_fleet_management_api/controllers/charging_controller.rb +62 -0
  10. data/lib/tesla_fleet_management_api/controllers/energy_controller.rb +315 -0
  11. data/lib/tesla_fleet_management_api/controllers/oauth_authorization_controller.rb +87 -0
  12. data/lib/tesla_fleet_management_api/controllers/partner_controller.rb +82 -0
  13. data/lib/tesla_fleet_management_api/controllers/user_controller.rb +73 -0
  14. data/lib/tesla_fleet_management_api/controllers/vehicles_controller.rb +431 -0
  15. data/lib/tesla_fleet_management_api/exceptions/api_exception.rb +21 -0
  16. data/lib/tesla_fleet_management_api/exceptions/oauth_provider_exception.rb +64 -0
  17. data/lib/tesla_fleet_management_api/http/api_response.rb +19 -0
  18. data/lib/tesla_fleet_management_api/http/auth/bearer_auth.rb +53 -0
  19. data/lib/tesla_fleet_management_api/http/auth/oauth_2.rb +154 -0
  20. data/lib/tesla_fleet_management_api/http/http_call_back.rb +10 -0
  21. data/lib/tesla_fleet_management_api/http/http_method_enum.rb +10 -0
  22. data/lib/tesla_fleet_management_api/http/http_request.rb +10 -0
  23. data/lib/tesla_fleet_management_api/http/http_response.rb +10 -0
  24. data/lib/tesla_fleet_management_api/http/proxy_settings.rb +22 -0
  25. data/lib/tesla_fleet_management_api/logging/configuration/api_logging_configuration.rb +186 -0
  26. data/lib/tesla_fleet_management_api/logging/sdk_logger.rb +17 -0
  27. data/lib/tesla_fleet_management_api/models/api1_dx_vehicles_options_response.rb +76 -0
  28. data/lib/tesla_fleet_management_api/models/api1_dx_warranty_details_response.rb +76 -0
  29. data/lib/tesla_fleet_management_api/models/api1_vehicles_mobile_enabled_response.rb +75 -0
  30. data/lib/tesla_fleet_management_api/models/api1_vehicles_nearby_charging_sites_response.rb +75 -0
  31. data/lib/tesla_fleet_management_api/models/api1_vehicles_response.rb +104 -0
  32. data/lib/tesla_fleet_management_api/models/api1_vehicles_response_get_vehicle.rb +75 -0
  33. data/lib/tesla_fleet_management_api/models/api1_vehicles_wake_up_response.rb +75 -0
  34. data/lib/tesla_fleet_management_api/models/backup_request.rb +75 -0
  35. data/lib/tesla_fleet_management_api/models/backup_response.rb +73 -0
  36. data/lib/tesla_fleet_management_api/models/base_model.rb +110 -0
  37. data/lib/tesla_fleet_management_api/models/calendar_history_response.rb +73 -0
  38. data/lib/tesla_fleet_management_api/models/charge_duration.rb +73 -0
  39. data/lib/tesla_fleet_management_api/models/charge_history.rb +96 -0
  40. data/lib/tesla_fleet_management_api/models/charge_history_response.rb +73 -0
  41. data/lib/tesla_fleet_management_api/models/charge_start_time.rb +73 -0
  42. data/lib/tesla_fleet_management_api/models/charging_dimension.rb +85 -0
  43. data/lib/tesla_fleet_management_api/models/charging_fee.rb +312 -0
  44. data/lib/tesla_fleet_management_api/models/charging_history_data.rb +81 -0
  45. data/lib/tesla_fleet_management_api/models/charging_history_item.rb +222 -0
  46. data/lib/tesla_fleet_management_api/models/charging_history_response.rb +73 -0
  47. data/lib/tesla_fleet_management_api/models/charging_invoice.rb +95 -0
  48. data/lib/tesla_fleet_management_api/models/charging_location.rb +158 -0
  49. data/lib/tesla_fleet_management_api/models/charging_period.rb +96 -0
  50. data/lib/tesla_fleet_management_api/models/charging_session.rb +187 -0
  51. data/lib/tesla_fleet_management_api/models/charging_sessions_data.rb +116 -0
  52. data/lib/tesla_fleet_management_api/models/charging_sessions_response.rb +73 -0
  53. data/lib/tesla_fleet_management_api/models/default_real_mode.rb +36 -0
  54. data/lib/tesla_fleet_management_api/models/driver.rb +164 -0
  55. data/lib/tesla_fleet_management_api/models/drivers_response.rb +94 -0
  56. data/lib/tesla_fleet_management_api/models/enterprise_payer_request.rb +94 -0
  57. data/lib/tesla_fleet_management_api/models/event.rb +89 -0
  58. data/lib/tesla_fleet_management_api/models/fleet_status_request.rb +74 -0
  59. data/lib/tesla_fleet_management_api/models/fleet_telemetry_error.rb +90 -0
  60. data/lib/tesla_fleet_management_api/models/fleet_telemetry_errors_response.rb +74 -0
  61. data/lib/tesla_fleet_management_api/models/fleet_telemetry_jws_request.rb +85 -0
  62. data/lib/tesla_fleet_management_api/models/generic_update_response.rb +73 -0
  63. data/lib/tesla_fleet_management_api/models/kind.rb +36 -0
  64. data/lib/tesla_fleet_management_api/models/kind_get_wall_connector_charging_history.rb +26 -0
  65. data/lib/tesla_fleet_management_api/models/live_status_response.rb +73 -0
  66. data/lib/tesla_fleet_management_api/models/location.rb +85 -0
  67. data/lib/tesla_fleet_management_api/models/location1.rb +85 -0
  68. data/lib/tesla_fleet_management_api/models/me_response.rb +73 -0
  69. data/lib/tesla_fleet_management_api/models/mobile_enabled.rb +85 -0
  70. data/lib/tesla_fleet_management_api/models/oauth_provider_error.rb +62 -0
  71. data/lib/tesla_fleet_management_api/models/oauth_token.rb +96 -0
  72. data/lib/tesla_fleet_management_api/models/off_grid_vehicle_charging_reserve_request.rb +79 -0
  73. data/lib/tesla_fleet_management_api/models/operation_request.rb +75 -0
  74. data/lib/tesla_fleet_management_api/models/orders_response.rb +91 -0
  75. data/lib/tesla_fleet_management_api/models/pagination.rb +127 -0
  76. data/lib/tesla_fleet_management_api/models/price_component.rb +95 -0
  77. data/lib/tesla_fleet_management_api/models/products_response.rb +85 -0
  78. data/lib/tesla_fleet_management_api/models/public_key_response.rb +73 -0
  79. data/lib/tesla_fleet_management_api/models/region_response.rb +73 -0
  80. data/lib/tesla_fleet_management_api/models/register_partner_request.rb +73 -0
  81. data/lib/tesla_fleet_management_api/models/register_partner_response.rb +73 -0
  82. data/lib/tesla_fleet_management_api/models/response.rb +82 -0
  83. data/lib/tesla_fleet_management_api/models/response1.rb +75 -0
  84. data/lib/tesla_fleet_management_api/models/response2.rb +74 -0
  85. data/lib/tesla_fleet_management_api/models/response3.rb +115 -0
  86. data/lib/tesla_fleet_management_api/models/response_api1_dx_vehicles_options_response.rb +84 -0
  87. data/lib/tesla_fleet_management_api/models/response_api1_dx_warranty_details_response.rb +124 -0
  88. data/lib/tesla_fleet_management_api/models/response_calendar_history_response.rb +91 -0
  89. data/lib/tesla_fleet_management_api/models/response_charge_history_response.rb +83 -0
  90. data/lib/tesla_fleet_management_api/models/response_fleet_telemetry_errors_response.rb +83 -0
  91. data/lib/tesla_fleet_management_api/models/response_live_status_response.rb +196 -0
  92. data/lib/tesla_fleet_management_api/models/response_me_response.rb +102 -0
  93. data/lib/tesla_fleet_management_api/models/response_orders_response.rb +157 -0
  94. data/lib/tesla_fleet_management_api/models/response_public_key_response.rb +74 -0
  95. data/lib/tesla_fleet_management_api/models/response_region_response.rb +83 -0
  96. data/lib/tesla_fleet_management_api/models/response_register_partner_response.rb +223 -0
  97. data/lib/tesla_fleet_management_api/models/signaling.rb +94 -0
  98. data/lib/tesla_fleet_management_api/models/simple_ok_response.rb +75 -0
  99. data/lib/tesla_fleet_management_api/models/site_info_response.rb +75 -0
  100. data/lib/tesla_fleet_management_api/models/storm_mode_request.rb +73 -0
  101. data/lib/tesla_fleet_management_api/models/tariff_element.rb +95 -0
  102. data/lib/tesla_fleet_management_api/models/tariffs.rb +94 -0
  103. data/lib/tesla_fleet_management_api/models/time_of_use_settings_request.rb +74 -0
  104. data/lib/tesla_fleet_management_api/models/total_cost.rb +95 -0
  105. data/lib/tesla_fleet_management_api/models/tou_settings.rb +77 -0
  106. data/lib/tesla_fleet_management_api/models/vehicle_base.rb +147 -0
  107. data/lib/tesla_fleet_management_api/models/vehicle_option.rb +107 -0
  108. data/lib/tesla_fleet_management_api/models/warranty_item.rb +155 -0
  109. data/lib/tesla_fleet_management_api/utilities/date_time_helper.rb +11 -0
  110. data/lib/tesla_fleet_management_api/utilities/file_wrapper.rb +28 -0
  111. data/lib/tesla_fleet_management_api.rb +153 -0
  112. metadata +195 -0
@@ -0,0 +1,154 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ # Utility class for OAuth 2 authorization and token management.
8
+ class Oauth2 < CoreLibrary::HeaderAuth
9
+ include CoreLibrary
10
+ # Display error message on occurrence of authentication failure.
11
+ # @returns [String] The oAuth error message.
12
+ def error_message
13
+ 'Oauth2: OAuthToken is undefined or expired.'
14
+ end
15
+
16
+ # Initialization constructor.
17
+ def initialize(oauth_2_credentials, config)
18
+ auth_params = {}
19
+ @_oauth_client_id = oauth_2_credentials.oauth_client_id unless
20
+ oauth_2_credentials.nil? || oauth_2_credentials.oauth_client_id.nil?
21
+ @_oauth_client_secret = oauth_2_credentials.oauth_client_secret unless
22
+ oauth_2_credentials.nil? || oauth_2_credentials.oauth_client_secret.nil?
23
+ @_oauth_redirect_uri = oauth_2_credentials.oauth_redirect_uri unless
24
+ oauth_2_credentials.nil? || oauth_2_credentials.oauth_redirect_uri.nil?
25
+ @_oauth_token = oauth_2_credentials.oauth_token unless
26
+ oauth_2_credentials.nil? || oauth_2_credentials.oauth_token.nil?
27
+ @_config = config
28
+ @_o_auth_api = OauthAuthorizationController.new(config)
29
+ auth_params[:Authorization] = "Bearer #{@_oauth_token.access_token}" unless @_oauth_token.nil?
30
+
31
+ super auth_params
32
+ end
33
+
34
+ # Validates the oAuth token.
35
+ # @return [Boolean] true if the token is present and not expired.
36
+ def valid
37
+ !@_oauth_token.nil? && !token_expired?(@_oauth_token)
38
+ end
39
+
40
+ # Builds and returns an authorization URL.
41
+ # The user is expected to obtain an authorization code from this URL and then call the
42
+ # fetch token function with that authorization code.
43
+ # @param [String] state An opaque state string.
44
+ # @param [Hash] additional_params Any additional query parameters to be added to the URL.
45
+ # @return [String] The authorization URL.
46
+ def get_authorization_url(state: nil, additional_params: nil)
47
+ auth_url = @_config.get_base_uri_executor.call(Server::AUTH_SERVER)
48
+ auth_url += '/authorize'
49
+ query_params = {
50
+ 'response_type' => 'code',
51
+ 'client_id' => @_oauth_client_id,
52
+ 'redirect_uri' => @_oauth_redirect_uri
53
+ }
54
+ query_params['scope'] = Array(@_o_auth_scopes).compact.join(' ') if @_o_auth_scopes
55
+ query_params['state'] = state if state
56
+ query_params.merge!(additional_params) if additional_params
57
+ auth_url = APIHelper.append_url_with_query_parameters(auth_url,
58
+ query_params)
59
+ APIHelper.clean_url(auth_url)
60
+ end
61
+
62
+ # Builds the basic auth header for endpoints in the OAuth Authorization Controller.
63
+ # @return [String] The value of the Authentication header.
64
+ def build_basic_auth_header
65
+ "Basic #{AuthHelper.get_base64_encoded_value(@_oauth_client_id, @_oauth_client_secret)}"
66
+ end
67
+
68
+ # Fetches the token.
69
+ # @param [String] auth_code The authentication code.
70
+ # @param [Hash] additional_params Any additional form parameters.
71
+ # @return [OAuthToken] The oAuth token instance.
72
+ def fetch_token(auth_code, additional_params: nil)
73
+ token = @_o_auth_api.request_token_oauth_2(
74
+ build_basic_auth_header,
75
+ auth_code,
76
+ @_oauth_redirect_uri,
77
+ _field_parameters: additional_params
78
+ ).data
79
+ if token.respond_to?('expires_in') && !token.expires_in.nil?
80
+ token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
81
+ end
82
+ token
83
+ end
84
+
85
+ # Checks if OAuth token has expired.
86
+ # @param [OAuthToken] token The oAuth token instance.
87
+ # @return [Boolean] true if the token is present and not expired.
88
+ def token_expired?(token)
89
+ token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry)
90
+ end
91
+
92
+ # Refreshes OAuth token.
93
+ # @param [Hash] additional_params Any additional form parameters.
94
+ # @return [OAuthToken] The oAuth token instance.
95
+ def refresh_token(additional_params: nil)
96
+ token = @_o_auth_api.refresh_token_oauth_2(
97
+ build_basic_auth_header,
98
+ @_oauth_token.refresh_token,
99
+ _field_parameters: additional_params
100
+ ).data
101
+ if token.respond_to?('expires_in') && !token.expires_in.nil?
102
+ token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
103
+ end
104
+ token
105
+ end
106
+ end
107
+
108
+ # Data class for Oauth2Credentials.
109
+ class Oauth2Credentials
110
+ attr_reader :oauth_client_id, :oauth_client_secret, :oauth_redirect_uri,
111
+ :oauth_token
112
+
113
+ def initialize(oauth_client_id:, oauth_client_secret:, oauth_redirect_uri:,
114
+ oauth_token: nil)
115
+ raise ArgumentError, 'oauth_client_id cannot be nil' if oauth_client_id.nil?
116
+ raise ArgumentError, 'oauth_client_secret cannot be nil' if oauth_client_secret.nil?
117
+ raise ArgumentError, 'oauth_redirect_uri cannot be nil' if oauth_redirect_uri.nil?
118
+
119
+ @oauth_client_id = oauth_client_id
120
+ @oauth_client_secret = oauth_client_secret
121
+ @oauth_redirect_uri = oauth_redirect_uri
122
+ @oauth_token = oauth_token
123
+ end
124
+
125
+ def self.from_env
126
+ oauth_client_id = ENV['OAUTH_2_OAUTH_CLIENT_ID']
127
+ oauth_client_secret = ENV['OAUTH_2_OAUTH_CLIENT_SECRET']
128
+ oauth_redirect_uri = ENV['OAUTH_2_OAUTH_REDIRECT_URI']
129
+ all_nil = [
130
+ oauth_client_id,
131
+ oauth_client_secret,
132
+ oauth_redirect_uri
133
+ ].all?(&:nil?)
134
+ return nil if all_nil
135
+
136
+ new(oauth_client_id: oauth_client_id,
137
+ oauth_client_secret: oauth_client_secret,
138
+ oauth_redirect_uri: oauth_redirect_uri)
139
+ end
140
+
141
+ def clone_with(oauth_client_id: nil, oauth_client_secret: nil,
142
+ oauth_redirect_uri: nil, oauth_token: nil)
143
+ oauth_client_id ||= self.oauth_client_id
144
+ oauth_client_secret ||= self.oauth_client_secret
145
+ oauth_redirect_uri ||= self.oauth_redirect_uri
146
+ oauth_token ||= self.oauth_token
147
+
148
+ Oauth2Credentials.new(oauth_client_id: oauth_client_id,
149
+ oauth_client_secret: oauth_client_secret,
150
+ oauth_redirect_uri: oauth_redirect_uri,
151
+ oauth_token: oauth_token)
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,10 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ # HttpCallBack allows defining callables for pre and post API calls.
8
+ class HttpCallBack < CoreLibrary::HttpCallback
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ # HTTP Methods Enumeration.
8
+ class HttpMethodEnum < CoreLibrary::HttpMethod
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ # Represents a single Http Request.
8
+ class HttpRequest < CoreLibrary::HttpRequest
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ # Http response received.
8
+ class HttpResponse < CoreLibrary::HttpResponse
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ ##
8
+ # ProxySettings encapsulates HTTP proxy configuration for Faraday,
9
+ # including optional basic authentication.
10
+ #
11
+ class ProxySettings < CoreLibrary::ProxySettings
12
+ def self.from_env
13
+ address = ENV['PROXY_ADDRESS']
14
+ port = ENV['PROXY_PORT']
15
+ username = ENV['PROXY_USERNAME']
16
+ password = ENV['PROXY_PASSWORD']
17
+ return nil if address.nil? || address.strip.empty?
18
+
19
+ new(address: address, port: port, username: username, password: password)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,186 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ # Initializes a new instance of RequestLoggingConfiguration.
8
+ class RequestLoggingConfiguration < CoreLibrary::ApiRequestLoggingConfiguration
9
+ # @param log_body [Boolean] Indicates whether the message body should be logged. Default is false.
10
+ # @param log_headers [Boolean] Indicates whether the message headers should be logged. Default is false.
11
+ # @param headers_to_exclude [Array<String>] Array of headers not displayed in logging. Default is an empty array.
12
+ # @param headers_to_include [Array<String>] Array of headers to be displayed in logging. Default is an empty array.
13
+ # @param headers_to_unmask [Array<String>] Array of headers which values are non-sensitive to display in logging.
14
+ # Default is an empty array.
15
+ def initialize(log_body: false, log_headers: false, headers_to_include: nil,
16
+ headers_to_exclude: nil, headers_to_unmask: nil,
17
+ include_query_in_path: false)
18
+ super(
19
+ log_body,
20
+ log_headers,
21
+ headers_to_exclude,
22
+ headers_to_include,
23
+ headers_to_unmask,
24
+ include_query_in_path
25
+ )
26
+ end
27
+
28
+ def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
29
+ headers_to_exclude: nil, headers_to_unmask: nil, include_query_in_path: nil)
30
+ log_body ||= self.log_body
31
+ log_headers ||= self.log_headers
32
+ headers_to_include ||= self.headers_to_include
33
+ headers_to_exclude ||= self.headers_to_exclude
34
+ headers_to_unmask ||= self.headers_to_unmask
35
+ include_query_in_path ||= self.include_query_in_path
36
+
37
+ RequestLoggingConfiguration.new(
38
+ log_body: log_body,
39
+ log_headers: log_headers,
40
+ headers_to_include: headers_to_include,
41
+ headers_to_exclude: headers_to_exclude,
42
+ headers_to_unmask: headers_to_unmask,
43
+ include_query_in_path: include_query_in_path
44
+ )
45
+ end
46
+
47
+ def self.from_env
48
+ log_body = ENV['REQUEST_LOG_BODY']
49
+ log_headers = ENV['REQUEST_LOG_HEADERS']
50
+ headers_to_include = ENV['REQUEST_HEADERS_TO_INCLUDE']
51
+ headers_to_exclude = ENV['REQUEST_HEADERS_TO_EXCLUDE']
52
+ headers_to_unmask = ENV['REQUEST_HEADERS_TO_UNMASK']
53
+ include_query_in_path = ENV['REQUEST_INCLUDE_QUERY_IN_PATH']
54
+
55
+ new(
56
+ log_body: log_body,
57
+ log_headers: log_headers,
58
+ headers_to_include: headers_to_include,
59
+ headers_to_exclude: headers_to_exclude,
60
+ headers_to_unmask: headers_to_unmask,
61
+ include_query_in_path: include_query_in_path
62
+ )
63
+ end
64
+
65
+ def self.any_logging_configured?
66
+ %w[
67
+ REQUEST_LOG_BODY
68
+ REQUEST_LOG_HEADERS
69
+ REQUEST_HEADERS_TO_INCLUDE
70
+ REQUEST_HEADERS_TO_EXCLUDE
71
+ REQUEST_HEADERS_TO_UNMASK
72
+ REQUEST_INCLUDE_QUERY_IN_PATH
73
+ ].any? { |key| ENV.key?(key) && !ENV[key].nil? && !ENV[key].empty? }
74
+ end
75
+ end
76
+
77
+ # Initializes a new instance of ResponseLoggingConfiguration.
78
+ class ResponseLoggingConfiguration < CoreLibrary::ApiResponseLoggingConfiguration
79
+ def initialize(log_body: false, log_headers: false, headers_to_include: nil,
80
+ headers_to_exclude: nil, headers_to_unmask: nil)
81
+ super(
82
+ log_body,
83
+ log_headers,
84
+ headers_to_exclude,
85
+ headers_to_include,
86
+ headers_to_unmask
87
+ )
88
+ end
89
+
90
+ def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
91
+ headers_to_exclude: nil, headers_to_unmask: nil)
92
+ log_body ||= self.log_body
93
+ log_headers ||= self.log_headers
94
+ headers_to_include ||= self.headers_to_include
95
+ headers_to_exclude ||= self.headers_to_exclude
96
+ headers_to_unmask ||= self.headers_to_unmask
97
+
98
+ ResponseLoggingConfiguration.new(
99
+ log_body: log_body,
100
+ log_headers: log_headers,
101
+ headers_to_include: headers_to_include,
102
+ headers_to_exclude: headers_to_exclude,
103
+ headers_to_unmask: headers_to_unmask
104
+ )
105
+ end
106
+
107
+ def self.from_env
108
+ log_body = ENV['RESPONSE_LOG_BODY']
109
+ log_headers = ENV['RESPONSE_LOG_HEADERS']
110
+ headers_to_include = ENV['RESPONSE_HEADERS_TO_INCLUDE']
111
+ headers_to_exclude = ENV['RESPONSE_HEADERS_TO_EXCLUDE']
112
+ headers_to_unmask = ENV['RESPONSE_HEADERS_TO_UNMASK']
113
+
114
+ new(
115
+ log_body: log_body,
116
+ log_headers: log_headers,
117
+ headers_to_include: headers_to_include,
118
+ headers_to_exclude: headers_to_exclude,
119
+ headers_to_unmask: headers_to_unmask
120
+ )
121
+ end
122
+
123
+ def self.any_logging_configured?
124
+ %w[
125
+ RESPONSE_LOG_BODY
126
+ RESPONSE_LOG_HEADERS
127
+ RESPONSE_HEADERS_TO_INCLUDE
128
+ RESPONSE_HEADERS_TO_EXCLUDE
129
+ RESPONSE_HEADERS_TO_UNMASK
130
+ ].any? { |key| ENV.key?(key) && !ENV[key].nil? && !ENV[key].empty? }
131
+ end
132
+ end
133
+
134
+ # Initializes a new instance of LoggingConfiguration.
135
+ class LoggingConfiguration < CoreLibrary::ApiLoggingConfiguration
136
+ def initialize(logger: nil, log_level: nil, mask_sensitive_headers: true,
137
+ request_logging_config: nil,
138
+ response_logging_config: nil)
139
+ request_logging_config ||= RequestLoggingConfiguration.new
140
+ response_logging_config ||= ResponseLoggingConfiguration.new
141
+ super(
142
+ logger,
143
+ log_level,
144
+ request_logging_config,
145
+ response_logging_config,
146
+ mask_sensitive_headers
147
+ )
148
+ end
149
+
150
+ def clone_with(logger: nil, log_level: nil, mask_sensitive_headers: nil,
151
+ request_logging_config: nil, response_logging_config: nil)
152
+ logger ||= self.logger
153
+ log_level ||= self.log_level
154
+ mask_sensitive_headers ||= self.mask_sensitive_headers
155
+ request_logging_config ||= self.request_logging_config.clone
156
+ response_logging_config ||= self.response_logging_config.clone
157
+
158
+ LoggingConfiguration.new(
159
+ logger: logger,
160
+ log_level: log_level,
161
+ mask_sensitive_headers: mask_sensitive_headers,
162
+ request_logging_config: request_logging_config,
163
+ response_logging_config: response_logging_config
164
+ )
165
+ end
166
+
167
+ def self.from_env
168
+ log_level = ENV['LOG_LEVEL']
169
+ mask_sensitive_headers = ENV['MASK_SENSITIVE_HEADERS']
170
+
171
+ new(
172
+ log_level: log_level,
173
+ mask_sensitive_headers: mask_sensitive_headers,
174
+ request_logging_config: RequestLoggingConfiguration.from_env,
175
+ response_logging_config: ResponseLoggingConfiguration.from_env
176
+ )
177
+ end
178
+
179
+ def self.any_logging_configured?
180
+ RequestLoggingConfiguration.any_logging_configured? ||
181
+ ResponseLoggingConfiguration.any_logging_configured? ||
182
+ ENV.key?('LOG_LEVEL') ||
183
+ ENV.key?('MASK_SENSITIVE_HEADERS')
184
+ end
185
+ end
186
+ end
@@ -0,0 +1,17 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ # Represents the generic logger facade
8
+ class AbstractLogger < Logger
9
+ # Logs a message with a specified log level and additional parameters.
10
+ # @param level [Symbol] The log level of the message.
11
+ # @param message [String] The message to log.
12
+ # @param params [Hash] Additional parameters to include in the log message.
13
+ def log(level, message, params)
14
+ raise NotImplementedError, 'This method needs to be implemented in a child class.'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,76 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ # Api1DxVehiclesOptionsResponse Model.
8
+ class Api1DxVehiclesOptionsResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [ResponseApi1DxVehiclesOptionsResponse]
14
+ attr_accessor :response
15
+
16
+ # A mapping from model property names to API property names.
17
+ def self.names
18
+ @_hash = {} if @_hash.nil?
19
+ @_hash['response'] = 'response'
20
+ @_hash
21
+ end
22
+
23
+ # An array for optional fields
24
+ def self.optionals
25
+ %w[
26
+ response
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def self.nullables
32
+ []
33
+ end
34
+
35
+ def initialize(response: SKIP, additional_properties: nil)
36
+ # Add additional model properties to the instance
37
+ additional_properties = {} if additional_properties.nil?
38
+
39
+ @response = response unless response == SKIP
40
+ @additional_properties = additional_properties
41
+ end
42
+
43
+ # Creates an instance of the object from a hash.
44
+ def self.from_hash(hash)
45
+ return nil unless hash
46
+
47
+ # Extract variables from the hash.
48
+ response = ResponseApi1DxVehiclesOptionsResponse.from_hash(hash['response']) if
49
+ hash['response']
50
+
51
+ # Create a new hash for additional properties, removing known properties.
52
+ new_hash = hash.reject { |k, _| names.value?(k) }
53
+
54
+ additional_properties = APIHelper.get_additional_properties(
55
+ new_hash, proc { |value| value }
56
+ )
57
+
58
+ # Create object from extracted values.
59
+ Api1DxVehiclesOptionsResponse.new(response: response,
60
+ additional_properties: additional_properties)
61
+ end
62
+
63
+ # Provides a human-readable string representation of the object.
64
+ def to_s
65
+ class_name = self.class.name.split('::').last
66
+ "<#{class_name} response: #{@response}, additional_properties: #{@additional_properties}>"
67
+ end
68
+
69
+ # Provides a debugging-friendly string with detailed object information.
70
+ def inspect
71
+ class_name = self.class.name.split('::').last
72
+ "<#{class_name} response: #{@response.inspect}, additional_properties:"\
73
+ " #{@additional_properties}>"
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,76 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ # Api1DxWarrantyDetailsResponse Model.
8
+ class Api1DxWarrantyDetailsResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [ResponseApi1DxWarrantyDetailsResponse]
14
+ attr_accessor :response
15
+
16
+ # A mapping from model property names to API property names.
17
+ def self.names
18
+ @_hash = {} if @_hash.nil?
19
+ @_hash['response'] = 'response'
20
+ @_hash
21
+ end
22
+
23
+ # An array for optional fields
24
+ def self.optionals
25
+ %w[
26
+ response
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def self.nullables
32
+ []
33
+ end
34
+
35
+ def initialize(response: SKIP, additional_properties: nil)
36
+ # Add additional model properties to the instance
37
+ additional_properties = {} if additional_properties.nil?
38
+
39
+ @response = response unless response == SKIP
40
+ @additional_properties = additional_properties
41
+ end
42
+
43
+ # Creates an instance of the object from a hash.
44
+ def self.from_hash(hash)
45
+ return nil unless hash
46
+
47
+ # Extract variables from the hash.
48
+ response = ResponseApi1DxWarrantyDetailsResponse.from_hash(hash['response']) if
49
+ hash['response']
50
+
51
+ # Create a new hash for additional properties, removing known properties.
52
+ new_hash = hash.reject { |k, _| names.value?(k) }
53
+
54
+ additional_properties = APIHelper.get_additional_properties(
55
+ new_hash, proc { |value| value }
56
+ )
57
+
58
+ # Create object from extracted values.
59
+ Api1DxWarrantyDetailsResponse.new(response: response,
60
+ additional_properties: additional_properties)
61
+ end
62
+
63
+ # Provides a human-readable string representation of the object.
64
+ def to_s
65
+ class_name = self.class.name.split('::').last
66
+ "<#{class_name} response: #{@response}, additional_properties: #{@additional_properties}>"
67
+ end
68
+
69
+ # Provides a debugging-friendly string with detailed object information.
70
+ def inspect
71
+ class_name = self.class.name.split('::').last
72
+ "<#{class_name} response: #{@response.inspect}, additional_properties:"\
73
+ " #{@additional_properties}>"
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,75 @@
1
+ # tesla_fleet_management_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TeslaFleetManagementApi
7
+ # Api1VehiclesMobileEnabledResponse Model.
8
+ class Api1VehiclesMobileEnabledResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [MobileEnabled]
14
+ attr_accessor :response
15
+
16
+ # A mapping from model property names to API property names.
17
+ def self.names
18
+ @_hash = {} if @_hash.nil?
19
+ @_hash['response'] = 'response'
20
+ @_hash
21
+ end
22
+
23
+ # An array for optional fields
24
+ def self.optionals
25
+ %w[
26
+ response
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def self.nullables
32
+ []
33
+ end
34
+
35
+ def initialize(response: SKIP, additional_properties: nil)
36
+ # Add additional model properties to the instance
37
+ additional_properties = {} if additional_properties.nil?
38
+
39
+ @response = response unless response == SKIP
40
+ @additional_properties = additional_properties
41
+ end
42
+
43
+ # Creates an instance of the object from a hash.
44
+ def self.from_hash(hash)
45
+ return nil unless hash
46
+
47
+ # Extract variables from the hash.
48
+ response = MobileEnabled.from_hash(hash['response']) if hash['response']
49
+
50
+ # Create a new hash for additional properties, removing known properties.
51
+ new_hash = hash.reject { |k, _| names.value?(k) }
52
+
53
+ additional_properties = APIHelper.get_additional_properties(
54
+ new_hash, proc { |value| value }
55
+ )
56
+
57
+ # Create object from extracted values.
58
+ Api1VehiclesMobileEnabledResponse.new(response: response,
59
+ additional_properties: additional_properties)
60
+ end
61
+
62
+ # Provides a human-readable string representation of the object.
63
+ def to_s
64
+ class_name = self.class.name.split('::').last
65
+ "<#{class_name} response: #{@response}, additional_properties: #{@additional_properties}>"
66
+ end
67
+
68
+ # Provides a debugging-friendly string with detailed object information.
69
+ def inspect
70
+ class_name = self.class.name.split('::').last
71
+ "<#{class_name} response: #{@response.inspect}, additional_properties:"\
72
+ " #{@additional_properties}>"
73
+ end
74
+ end
75
+ end