Enhance MySubaru API integration with improved error handling and new utility functions
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s
- Refactor Response struct's parse method to return detailed error messages based on API error codes. - Introduce UnixTime type for handling Unix timestamps in JSON marshaling and unmarshaling. - Add email masking utility function to obfuscate email addresses for privacy. - Implement containsValueInStruct function to check for substring presence in struct fields. - Create comprehensive unit tests for UnixTime, email masking, and struct value checking. - Update vehicle service request method documentation for clarity.
This commit is contained in:
34
consts.go
34
consts.go
@ -95,23 +95,23 @@ var apiURLs = map[string]string{
|
||||
// }
|
||||
|
||||
var API_ERRORS = map[string]string{
|
||||
"403-soa-unableToParseResponseBody": "ERROR_SOA_403", // G2 Error Codes
|
||||
"InvalidCredentials": "ERROR_INVALID_CREDENTIALS",
|
||||
"ServiceAlreadyStarted": "ERROR_SERVICE_ALREADY_STARTED",
|
||||
"invalidAccount": "ERROR_INVALID_ACCOUNT",
|
||||
"passwordWarning": "ERROR_PASSWORD_WARNING",
|
||||
"accountLocked": "ERROR_ACCOUNT_LOCKED",
|
||||
"noVehiclesOnAccount": "ERROR_NO_VEHICLES",
|
||||
"noVehiclesAvailable": "ERROR_NO_VEHICLE_AVAILABLE",
|
||||
"VEHICLESETUPERROR": "ERROR_VEHICLE_SETUP_ERROR", // Vehicle Select
|
||||
"accountNotFound": "ERROR_NO_ACCOUNT",
|
||||
"tooManyAttempts": "ERROR_TOO_MANY_ATTEMPTS",
|
||||
"vehicleNotInAccount": "ERROR_VEHICLE_NOT_IN_ACCOUNT",
|
||||
"SXM40004": "ERROR_G1_NO_SUBSCRIPTION", // G1 Error Codes
|
||||
"SXM40005": "ERROR_G1_STOLEN_VEHICLE",
|
||||
"SXM40006": "ERROR_G1_INVALID_PIN",
|
||||
"SXM40009": "ERROR_G1_SERVICE_ALREADY_STARTED",
|
||||
"SXM40017": "ERROR_G1_PIN_LOCKED",
|
||||
"API_ERROR_SOA_403": "403-soa-unableToParseResponseBody", // G2
|
||||
"API_ERROR_NO_ACCOUNT": "accountNotFound", // G2
|
||||
"API_ERROR_INVALID_ACCOUNT": "invalidAccount", // G2
|
||||
"API_ERROR_INVALID_CREDENTIALS": "InvalidCredentials", // G2
|
||||
"API_ERROR_INVALID_TOKEN": "InvalidToken", // G2
|
||||
"API_ERROR_PASSWORD_WARNING": "passwordWarning", // G2
|
||||
"API_ERROR_TOO_MANY_ATTEMPTS": "tooManyAttempts", // G2
|
||||
"API_ERROR_ACCOUNT_LOCKED": "accountLocked", // G2
|
||||
"API_ERROR_NO_VEHICLES": "noVehiclesOnAccount", // G2
|
||||
"API_ERROR_VEHICLE_SETUP": "VEHICLESETUPERROR", // G2
|
||||
"API_ERROR_VEHICLE_NOT_IN_ACCOUNT": "vehicleNotInAccount", // G2
|
||||
"API_ERROR_SERVICE_ALREADY_STARTED": "ServiceAlreadyStarted", // G2
|
||||
"API_ERROR_G1_NO_SUBSCRIPTION": "SXM40004", // G1
|
||||
"API_ERROR_G1_STOLEN_VEHICLE": "SXM40005", // G1
|
||||
"API_ERROR_G1_INVALID_PIN": "SXM40006", // G1
|
||||
"API_ERROR_G1_SERVICE_ALREADY_STARTED": "SXM40009", // G1
|
||||
"API_ERROR_G1_PIN_LOCKED": "SXM40017", // G1
|
||||
}
|
||||
|
||||
var APP_ERRORS = map[string]string{
|
||||
|
Reference in New Issue
Block a user