tesla-api-sdk 1.0.0 → 1.0.1

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 (29) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -31
  3. data/lib/tesla_fleet_management_api/client.rb +14 -8
  4. data/lib/tesla_fleet_management_api/configuration.rb +8 -8
  5. data/lib/tesla_fleet_management_api/controllers/base_controller.rb +1 -1
  6. data/lib/tesla_fleet_management_api/controllers/charging_controller.rb +3 -3
  7. data/lib/tesla_fleet_management_api/controllers/energy_controller.rb +11 -11
  8. data/lib/tesla_fleet_management_api/controllers/{oauth_authorization_controller.rb → o_auth_authorization_controller.rb} +16 -16
  9. data/lib/tesla_fleet_management_api/controllers/partner_controller.rb +4 -4
  10. data/lib/tesla_fleet_management_api/controllers/user_controller.rb +4 -4
  11. data/lib/tesla_fleet_management_api/controllers/vehicle_commands_controller.rb +486 -0
  12. data/lib/tesla_fleet_management_api/controllers/vehicles_controller.rb +21 -21
  13. data/lib/tesla_fleet_management_api/exceptions/{oauth_provider_exception.rb → o_auth_provider_exception.rb} +2 -2
  14. data/lib/tesla_fleet_management_api/http/auth/oauth2.rb +163 -0
  15. data/lib/tesla_fleet_management_api/models/actuate_trunk_request.rb +74 -0
  16. data/lib/tesla_fleet_management_api/models/add_charge_schedule_request.rb +160 -0
  17. data/lib/tesla_fleet_management_api/models/add_precondition_schedule_request.rb +132 -0
  18. data/lib/tesla_fleet_management_api/models/adjust_volume_request.rb +73 -0
  19. data/lib/tesla_fleet_management_api/models/command_response.rb +75 -0
  20. data/lib/tesla_fleet_management_api/models/command_result.rb +82 -0
  21. data/lib/tesla_fleet_management_api/models/guest_mode_request.rb +73 -0
  22. data/lib/tesla_fleet_management_api/models/kind_get_wall_connector_charging_history.rb +1 -1
  23. data/lib/tesla_fleet_management_api/models/{oauth_provider_error.rb → o_auth_provider_error.rb} +3 -3
  24. data/lib/tesla_fleet_management_api/models/o_auth_scope_oauth2.rb +82 -0
  25. data/lib/tesla_fleet_management_api/models/{oauth_token.rb → o_auth_token.rb} +2 -2
  26. data/lib/tesla_fleet_management_api/models/which_trunk.rb +36 -0
  27. data/lib/tesla_fleet_management_api.rb +17 -5
  28. metadata +17 -7
  29. data/lib/tesla_fleet_management_api/http/auth/oauth_2.rb +0 -154
@@ -5,12 +5,12 @@
5
5
 
6
6
  module TeslaFleetManagementApi
7
7
  # OAuth 2 Authorization endpoint exception.
8
- class OauthProviderException < APIException
8
+ class OAuthProviderException < APIException
9
9
  SKIP = Object.new
10
10
  private_constant :SKIP
11
11
 
12
12
  # Gets or sets error code.
13
- # @return [OauthProviderError]
13
+ # @return [OAuthProviderError]
14
14
  attr_accessor :error
15
15
 
16
16
  # Gets or sets human-readable text providing additional information on
@@ -0,0 +1,163 @@
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(oauth2_credentials, config)
18
+ auth_params = {}
19
+ @_o_auth_client_id = oauth2_credentials.o_auth_client_id unless
20
+ oauth2_credentials.nil? || oauth2_credentials.o_auth_client_id.nil?
21
+ @_o_auth_client_secret = oauth2_credentials.o_auth_client_secret unless
22
+ oauth2_credentials.nil? || oauth2_credentials.o_auth_client_secret.nil?
23
+ @_o_auth_redirect_uri = oauth2_credentials.o_auth_redirect_uri unless
24
+ oauth2_credentials.nil? || oauth2_credentials.o_auth_redirect_uri.nil?
25
+ @_o_auth_token = oauth2_credentials.o_auth_token unless
26
+ oauth2_credentials.nil? || oauth2_credentials.o_auth_token.nil?
27
+ @_o_auth_scopes = oauth2_credentials.o_auth_scopes unless
28
+ oauth2_credentials.nil? || oauth2_credentials.o_auth_scopes.nil?
29
+ @_config = config
30
+ @_o_auth_api = OAuthAuthorizationController.new(config)
31
+ auth_params[:Authorization] = "Bearer #{@_o_auth_token.access_token}" unless @_o_auth_token.nil?
32
+
33
+ super auth_params
34
+ end
35
+
36
+ # Validates the oAuth token.
37
+ # @return [Boolean] true if the token is present and not expired.
38
+ def valid
39
+ !@_o_auth_token.nil? && !token_expired?(@_o_auth_token)
40
+ end
41
+
42
+ # Builds and returns an authorization URL.
43
+ # The user is expected to obtain an authorization code from this URL and then call the
44
+ # fetch token function with that authorization code.
45
+ # @param [String] state An opaque state string.
46
+ # @param [Hash] additional_params Any additional query parameters to be added to the URL.
47
+ # @return [String] The authorization URL.
48
+ def get_authorization_url(state: nil, additional_params: nil)
49
+ auth_url = @_config.get_base_uri_executor.call(Server::AUTH_SERVER)
50
+ auth_url += '/authorize'
51
+ query_params = {
52
+ 'response_type' => 'code',
53
+ 'client_id' => @_o_auth_client_id,
54
+ 'redirect_uri' => @_o_auth_redirect_uri
55
+ }
56
+ query_params['scope'] = Array(@_o_auth_scopes).compact.join(' ') if @_o_auth_scopes
57
+ query_params['state'] = state if state
58
+ query_params.merge!(additional_params) if additional_params
59
+ auth_url = APIHelper.append_url_with_query_parameters(auth_url,
60
+ query_params)
61
+ APIHelper.clean_url(auth_url)
62
+ end
63
+
64
+ # Builds the basic auth header for endpoints in the OAuth Authorization Controller.
65
+ # @return [String] The value of the Authentication header.
66
+ def build_basic_auth_header
67
+ "Basic #{AuthHelper.get_base64_encoded_value(@_o_auth_client_id, @_o_auth_client_secret)}"
68
+ end
69
+
70
+ # Fetches the token.
71
+ # @param [String] auth_code The authentication code.
72
+ # @param [Hash] additional_params Any additional form parameters.
73
+ # @return [OAuthToken] The oAuth token instance.
74
+ def fetch_token(auth_code, additional_params: nil)
75
+ token = @_o_auth_api.request_token_oauth2(
76
+ build_basic_auth_header,
77
+ auth_code,
78
+ @_o_auth_redirect_uri,
79
+ _field_parameters: additional_params
80
+ ).data
81
+ if token.respond_to?('expires_in') && !token.expires_in.nil?
82
+ token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
83
+ end
84
+ token
85
+ end
86
+
87
+ # Checks if OAuth token has expired.
88
+ # @param [OAuthToken] token The oAuth token instance.
89
+ # @return [Boolean] true if the token is present and not expired.
90
+ def token_expired?(token)
91
+ token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry)
92
+ end
93
+
94
+ # Refreshes OAuth token.
95
+ # @param [Hash] additional_params Any additional form parameters.
96
+ # @return [OAuthToken] The oAuth token instance.
97
+ def refresh_token(additional_params: nil)
98
+ token = @_o_auth_api.refresh_token_oauth2(
99
+ build_basic_auth_header,
100
+ @_o_auth_token.refresh_token,
101
+ scope: !@_o_auth_scopes.nil? ? Array(@_o_auth_scopes).compact.join(' ') : nil,
102
+ _field_parameters: additional_params
103
+ ).data
104
+ if token.respond_to?('expires_in') && !token.expires_in.nil?
105
+ token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
106
+ end
107
+ token
108
+ end
109
+ end
110
+
111
+ # Data class for Oauth2Credentials.
112
+ class Oauth2Credentials
113
+ attr_reader :o_auth_client_id, :o_auth_client_secret, :o_auth_redirect_uri,
114
+ :o_auth_token, :o_auth_scopes
115
+
116
+ def initialize(o_auth_client_id:, o_auth_client_secret:,
117
+ o_auth_redirect_uri:, o_auth_token: nil, o_auth_scopes: nil)
118
+ raise ArgumentError, 'o_auth_client_id cannot be nil' if o_auth_client_id.nil?
119
+ raise ArgumentError, 'o_auth_client_secret cannot be nil' if o_auth_client_secret.nil?
120
+ raise ArgumentError, 'o_auth_redirect_uri cannot be nil' if o_auth_redirect_uri.nil?
121
+
122
+ @o_auth_client_id = o_auth_client_id
123
+ @o_auth_client_secret = o_auth_client_secret
124
+ @o_auth_redirect_uri = o_auth_redirect_uri
125
+ @o_auth_token = o_auth_token
126
+ @o_auth_scopes = o_auth_scopes
127
+ end
128
+
129
+ def self.from_env
130
+ o_auth_client_id = ENV['OAUTH2_O_AUTH_CLIENT_ID']
131
+ o_auth_client_secret = ENV['OAUTH2_O_AUTH_CLIENT_SECRET']
132
+ o_auth_redirect_uri = ENV['OAUTH2_O_AUTH_REDIRECT_URI']
133
+ o_auth_scopes = ENV['OAUTH2_O_AUTH_SCOPES']
134
+ all_nil = [
135
+ o_auth_client_id,
136
+ o_auth_client_secret,
137
+ o_auth_redirect_uri
138
+ ].all?(&:nil?)
139
+ return nil if all_nil
140
+
141
+ new(o_auth_client_id: o_auth_client_id,
142
+ o_auth_client_secret: o_auth_client_secret,
143
+ o_auth_redirect_uri: o_auth_redirect_uri,
144
+ o_auth_scopes: o_auth_scopes)
145
+ end
146
+
147
+ def clone_with(o_auth_client_id: nil, o_auth_client_secret: nil,
148
+ o_auth_redirect_uri: nil, o_auth_token: nil,
149
+ o_auth_scopes: nil)
150
+ o_auth_client_id ||= self.o_auth_client_id
151
+ o_auth_client_secret ||= self.o_auth_client_secret
152
+ o_auth_redirect_uri ||= self.o_auth_redirect_uri
153
+ o_auth_token ||= self.o_auth_token
154
+ o_auth_scopes ||= self.o_auth_scopes
155
+
156
+ Oauth2Credentials.new(o_auth_client_id: o_auth_client_id,
157
+ o_auth_client_secret: o_auth_client_secret,
158
+ o_auth_redirect_uri: o_auth_redirect_uri,
159
+ o_auth_token: o_auth_token,
160
+ o_auth_scopes: o_auth_scopes)
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,74 @@
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
+ # ActuateTrunkRequest Model.
8
+ class ActuateTrunkRequest < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [WhichTrunk]
14
+ attr_accessor :which_trunk
15
+
16
+ # A mapping from model property names to API property names.
17
+ def self.names
18
+ @_hash = {} if @_hash.nil?
19
+ @_hash['which_trunk'] = 'which_trunk'
20
+ @_hash
21
+ end
22
+
23
+ # An array for optional fields
24
+ def self.optionals
25
+ []
26
+ end
27
+
28
+ # An array for nullable fields
29
+ def self.nullables
30
+ []
31
+ end
32
+
33
+ def initialize(which_trunk:, additional_properties: nil)
34
+ # Add additional model properties to the instance
35
+ additional_properties = {} if additional_properties.nil?
36
+
37
+ @which_trunk = which_trunk
38
+ @additional_properties = additional_properties
39
+ end
40
+
41
+ # Creates an instance of the object from a hash.
42
+ def self.from_hash(hash)
43
+ return nil unless hash
44
+
45
+ # Extract variables from the hash.
46
+ which_trunk = hash.key?('which_trunk') ? hash['which_trunk'] : nil
47
+
48
+ # Create a new hash for additional properties, removing known properties.
49
+ new_hash = hash.reject { |k, _| names.value?(k) }
50
+
51
+ additional_properties = APIHelper.get_additional_properties(
52
+ new_hash, proc { |value| value }
53
+ )
54
+
55
+ # Create object from extracted values.
56
+ ActuateTrunkRequest.new(which_trunk: which_trunk,
57
+ additional_properties: additional_properties)
58
+ end
59
+
60
+ # Provides a human-readable string representation of the object.
61
+ def to_s
62
+ class_name = self.class.name.split('::').last
63
+ "<#{class_name} which_trunk: #{@which_trunk}, additional_properties:"\
64
+ " #{@additional_properties}>"
65
+ end
66
+
67
+ # Provides a debugging-friendly string with detailed object information.
68
+ def inspect
69
+ class_name = self.class.name.split('::').last
70
+ "<#{class_name} which_trunk: #{@which_trunk.inspect}, additional_properties:"\
71
+ " #{@additional_properties}>"
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,160 @@
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
+ # AddChargeScheduleRequest Model.
8
+ class AddChargeScheduleRequest < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Float]
14
+ attr_accessor :lat
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [Float]
18
+ attr_accessor :lon
19
+
20
+ # TODO: Write general description for this method
21
+ # @return [Integer]
22
+ attr_accessor :id
23
+
24
+ # TODO: Write general description for this method
25
+ # @return [String]
26
+ attr_accessor :days_of_week
27
+
28
+ # TODO: Write general description for this method
29
+ # @return [TrueClass | FalseClass]
30
+ attr_accessor :start_enabled
31
+
32
+ # TODO: Write general description for this method
33
+ # @return [Integer]
34
+ attr_accessor :start_time
35
+
36
+ # TODO: Write general description for this method
37
+ # @return [TrueClass | FalseClass]
38
+ attr_accessor :end_enabled
39
+
40
+ # TODO: Write general description for this method
41
+ # @return [Integer]
42
+ attr_accessor :end_time
43
+
44
+ # TODO: Write general description for this method
45
+ # @return [TrueClass | FalseClass]
46
+ attr_accessor :one_time
47
+
48
+ # TODO: Write general description for this method
49
+ # @return [TrueClass | FalseClass]
50
+ attr_accessor :enabled
51
+
52
+ # A mapping from model property names to API property names.
53
+ def self.names
54
+ @_hash = {} if @_hash.nil?
55
+ @_hash['lat'] = 'lat'
56
+ @_hash['lon'] = 'lon'
57
+ @_hash['id'] = 'id'
58
+ @_hash['days_of_week'] = 'days_of_week'
59
+ @_hash['start_enabled'] = 'start_enabled'
60
+ @_hash['start_time'] = 'start_time'
61
+ @_hash['end_enabled'] = 'end_enabled'
62
+ @_hash['end_time'] = 'end_time'
63
+ @_hash['one_time'] = 'one_time'
64
+ @_hash['enabled'] = 'enabled'
65
+ @_hash
66
+ end
67
+
68
+ # An array for optional fields
69
+ def self.optionals
70
+ %w[
71
+ days_of_week
72
+ start_enabled
73
+ start_time
74
+ end_enabled
75
+ end_time
76
+ one_time
77
+ ]
78
+ end
79
+
80
+ # An array for nullable fields
81
+ def self.nullables
82
+ []
83
+ end
84
+
85
+ def initialize(lat:, lon:, id:, enabled:, days_of_week: SKIP,
86
+ start_enabled: SKIP, start_time: SKIP, end_enabled: SKIP,
87
+ end_time: SKIP, one_time: SKIP, additional_properties: nil)
88
+ # Add additional model properties to the instance
89
+ additional_properties = {} if additional_properties.nil?
90
+
91
+ @lat = lat
92
+ @lon = lon
93
+ @id = id
94
+ @days_of_week = days_of_week unless days_of_week == SKIP
95
+ @start_enabled = start_enabled unless start_enabled == SKIP
96
+ @start_time = start_time unless start_time == SKIP
97
+ @end_enabled = end_enabled unless end_enabled == SKIP
98
+ @end_time = end_time unless end_time == SKIP
99
+ @one_time = one_time unless one_time == SKIP
100
+ @enabled = enabled
101
+ @additional_properties = additional_properties
102
+ end
103
+
104
+ # Creates an instance of the object from a hash.
105
+ def self.from_hash(hash)
106
+ return nil unless hash
107
+
108
+ # Extract variables from the hash.
109
+ lat = hash.key?('lat') ? hash['lat'] : nil
110
+ lon = hash.key?('lon') ? hash['lon'] : nil
111
+ id = hash.key?('id') ? hash['id'] : nil
112
+ enabled = hash.key?('enabled') ? hash['enabled'] : nil
113
+ days_of_week = hash.key?('days_of_week') ? hash['days_of_week'] : SKIP
114
+ start_enabled = hash.key?('start_enabled') ? hash['start_enabled'] : SKIP
115
+ start_time = hash.key?('start_time') ? hash['start_time'] : SKIP
116
+ end_enabled = hash.key?('end_enabled') ? hash['end_enabled'] : SKIP
117
+ end_time = hash.key?('end_time') ? hash['end_time'] : SKIP
118
+ one_time = hash.key?('one_time') ? hash['one_time'] : SKIP
119
+
120
+ # Create a new hash for additional properties, removing known properties.
121
+ new_hash = hash.reject { |k, _| names.value?(k) }
122
+
123
+ additional_properties = APIHelper.get_additional_properties(
124
+ new_hash, proc { |value| value }
125
+ )
126
+
127
+ # Create object from extracted values.
128
+ AddChargeScheduleRequest.new(lat: lat,
129
+ lon: lon,
130
+ id: id,
131
+ enabled: enabled,
132
+ days_of_week: days_of_week,
133
+ start_enabled: start_enabled,
134
+ start_time: start_time,
135
+ end_enabled: end_enabled,
136
+ end_time: end_time,
137
+ one_time: one_time,
138
+ additional_properties: additional_properties)
139
+ end
140
+
141
+ # Provides a human-readable string representation of the object.
142
+ def to_s
143
+ class_name = self.class.name.split('::').last
144
+ "<#{class_name} lat: #{@lat}, lon: #{@lon}, id: #{@id}, days_of_week: #{@days_of_week},"\
145
+ " start_enabled: #{@start_enabled}, start_time: #{@start_time}, end_enabled:"\
146
+ " #{@end_enabled}, end_time: #{@end_time}, one_time: #{@one_time}, enabled: #{@enabled},"\
147
+ " additional_properties: #{@additional_properties}>"
148
+ end
149
+
150
+ # Provides a debugging-friendly string with detailed object information.
151
+ def inspect
152
+ class_name = self.class.name.split('::').last
153
+ "<#{class_name} lat: #{@lat.inspect}, lon: #{@lon.inspect}, id: #{@id.inspect},"\
154
+ " days_of_week: #{@days_of_week.inspect}, start_enabled: #{@start_enabled.inspect},"\
155
+ " start_time: #{@start_time.inspect}, end_enabled: #{@end_enabled.inspect}, end_time:"\
156
+ " #{@end_time.inspect}, one_time: #{@one_time.inspect}, enabled: #{@enabled.inspect},"\
157
+ " additional_properties: #{@additional_properties}>"
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,132 @@
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
+ # AddPreconditionScheduleRequest Model.
8
+ class AddPreconditionScheduleRequest < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Float]
14
+ attr_accessor :lat
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [Float]
18
+ attr_accessor :lon
19
+
20
+ # TODO: Write general description for this method
21
+ # @return [Integer]
22
+ attr_accessor :id
23
+
24
+ # TODO: Write general description for this method
25
+ # @return [String]
26
+ attr_accessor :days_of_week
27
+
28
+ # TODO: Write general description for this method
29
+ # @return [Integer]
30
+ attr_accessor :precondition_time
31
+
32
+ # TODO: Write general description for this method
33
+ # @return [TrueClass | FalseClass]
34
+ attr_accessor :one_time
35
+
36
+ # TODO: Write general description for this method
37
+ # @return [TrueClass | FalseClass]
38
+ attr_accessor :enabled
39
+
40
+ # A mapping from model property names to API property names.
41
+ def self.names
42
+ @_hash = {} if @_hash.nil?
43
+ @_hash['lat'] = 'lat'
44
+ @_hash['lon'] = 'lon'
45
+ @_hash['id'] = 'id'
46
+ @_hash['days_of_week'] = 'days_of_week'
47
+ @_hash['precondition_time'] = 'precondition_time'
48
+ @_hash['one_time'] = 'one_time'
49
+ @_hash['enabled'] = 'enabled'
50
+ @_hash
51
+ end
52
+
53
+ # An array for optional fields
54
+ def self.optionals
55
+ %w[
56
+ days_of_week
57
+ precondition_time
58
+ one_time
59
+ ]
60
+ end
61
+
62
+ # An array for nullable fields
63
+ def self.nullables
64
+ []
65
+ end
66
+
67
+ def initialize(lat:, lon:, id:, enabled:, days_of_week: SKIP,
68
+ precondition_time: SKIP, one_time: SKIP,
69
+ additional_properties: nil)
70
+ # Add additional model properties to the instance
71
+ additional_properties = {} if additional_properties.nil?
72
+
73
+ @lat = lat
74
+ @lon = lon
75
+ @id = id
76
+ @days_of_week = days_of_week unless days_of_week == SKIP
77
+ @precondition_time = precondition_time unless precondition_time == SKIP
78
+ @one_time = one_time unless one_time == SKIP
79
+ @enabled = enabled
80
+ @additional_properties = additional_properties
81
+ end
82
+
83
+ # Creates an instance of the object from a hash.
84
+ def self.from_hash(hash)
85
+ return nil unless hash
86
+
87
+ # Extract variables from the hash.
88
+ lat = hash.key?('lat') ? hash['lat'] : nil
89
+ lon = hash.key?('lon') ? hash['lon'] : nil
90
+ id = hash.key?('id') ? hash['id'] : nil
91
+ enabled = hash.key?('enabled') ? hash['enabled'] : nil
92
+ days_of_week = hash.key?('days_of_week') ? hash['days_of_week'] : SKIP
93
+ precondition_time =
94
+ hash.key?('precondition_time') ? hash['precondition_time'] : SKIP
95
+ one_time = hash.key?('one_time') ? hash['one_time'] : SKIP
96
+
97
+ # Create a new hash for additional properties, removing known properties.
98
+ new_hash = hash.reject { |k, _| names.value?(k) }
99
+
100
+ additional_properties = APIHelper.get_additional_properties(
101
+ new_hash, proc { |value| value }
102
+ )
103
+
104
+ # Create object from extracted values.
105
+ AddPreconditionScheduleRequest.new(lat: lat,
106
+ lon: lon,
107
+ id: id,
108
+ enabled: enabled,
109
+ days_of_week: days_of_week,
110
+ precondition_time: precondition_time,
111
+ one_time: one_time,
112
+ additional_properties: additional_properties)
113
+ end
114
+
115
+ # Provides a human-readable string representation of the object.
116
+ def to_s
117
+ class_name = self.class.name.split('::').last
118
+ "<#{class_name} lat: #{@lat}, lon: #{@lon}, id: #{@id}, days_of_week: #{@days_of_week},"\
119
+ " precondition_time: #{@precondition_time}, one_time: #{@one_time}, enabled: #{@enabled},"\
120
+ " additional_properties: #{@additional_properties}>"
121
+ end
122
+
123
+ # Provides a debugging-friendly string with detailed object information.
124
+ def inspect
125
+ class_name = self.class.name.split('::').last
126
+ "<#{class_name} lat: #{@lat.inspect}, lon: #{@lon.inspect}, id: #{@id.inspect},"\
127
+ " days_of_week: #{@days_of_week.inspect}, precondition_time: #{@precondition_time.inspect},"\
128
+ " one_time: #{@one_time.inspect}, enabled: #{@enabled.inspect}, additional_properties:"\
129
+ " #{@additional_properties}>"
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,73 @@
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
+ # AdjustVolumeRequest Model.
8
+ class AdjustVolumeRequest < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Integer]
14
+ attr_accessor :volume
15
+
16
+ # A mapping from model property names to API property names.
17
+ def self.names
18
+ @_hash = {} if @_hash.nil?
19
+ @_hash['volume'] = 'volume'
20
+ @_hash
21
+ end
22
+
23
+ # An array for optional fields
24
+ def self.optionals
25
+ []
26
+ end
27
+
28
+ # An array for nullable fields
29
+ def self.nullables
30
+ []
31
+ end
32
+
33
+ def initialize(volume:, additional_properties: nil)
34
+ # Add additional model properties to the instance
35
+ additional_properties = {} if additional_properties.nil?
36
+
37
+ @volume = volume
38
+ @additional_properties = additional_properties
39
+ end
40
+
41
+ # Creates an instance of the object from a hash.
42
+ def self.from_hash(hash)
43
+ return nil unless hash
44
+
45
+ # Extract variables from the hash.
46
+ volume = hash.key?('volume') ? hash['volume'] : nil
47
+
48
+ # Create a new hash for additional properties, removing known properties.
49
+ new_hash = hash.reject { |k, _| names.value?(k) }
50
+
51
+ additional_properties = APIHelper.get_additional_properties(
52
+ new_hash, proc { |value| value }
53
+ )
54
+
55
+ # Create object from extracted values.
56
+ AdjustVolumeRequest.new(volume: volume,
57
+ additional_properties: additional_properties)
58
+ end
59
+
60
+ # Provides a human-readable string representation of the object.
61
+ def to_s
62
+ class_name = self.class.name.split('::').last
63
+ "<#{class_name} volume: #{@volume}, additional_properties: #{@additional_properties}>"
64
+ end
65
+
66
+ # Provides a debugging-friendly string with detailed object information.
67
+ def inspect
68
+ class_name = self.class.name.split('::').last
69
+ "<#{class_name} volume: #{@volume.inspect}, additional_properties:"\
70
+ " #{@additional_properties}>"
71
+ end
72
+ end
73
+ 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
+ # CommandResponse Model.
8
+ class CommandResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [CommandResult]
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 = CommandResult.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
+ CommandResponse.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