Some updates
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
This commit is contained in:
19
client.go
19
client.go
@ -226,7 +226,7 @@ func New(config *config.Config) (*Client, error) {
|
|||||||
resp := client.auth()
|
resp := client.auth()
|
||||||
respParsed, err := gabs.ParseJSON(resp)
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
client.logger.Error("error which parsing json", "request", "auth", "error", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.isResponseSuccessfull(resp) {
|
if client.isResponseSuccessfull(resp) {
|
||||||
@ -281,6 +281,7 @@ func (c *Client) SelectVehicle(vin string) VehicleData {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
c.logger.Debug("http request output", "request", "SelectVehicle", "body", respParsed)
|
||||||
|
|
||||||
vdString := respParsed.Path("data").String()
|
vdString := respParsed.Path("data").String()
|
||||||
json.Unmarshal([]byte(vdString), &vData)
|
json.Unmarshal([]byte(vdString), &vData)
|
||||||
@ -325,6 +326,7 @@ func (c *Client) GetVehicles() []*Vehicle {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Error("error which parsing json", "request", "GetVehicles", "error", err.Error())
|
c.logger.Error("error which parsing json", "request", "GetVehicles", "error", err.Error())
|
||||||
}
|
}
|
||||||
|
c.logger.Debug("http request output", "request", "GetVehicles", "body", respParsed)
|
||||||
|
|
||||||
vData := VehicleData{}
|
vData := VehicleData{}
|
||||||
vdString := respParsed.Path("data").String()
|
vdString := respParsed.Path("data").String()
|
||||||
@ -377,13 +379,12 @@ func (c *Client) GetVehicleByVIN(vin string) *Vehicle {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Error("error which parsing json", "request", "GetVehicleByVIN", "error", err.Error())
|
c.logger.Error("error which parsing json", "request", "GetVehicleByVIN", "error", err.Error())
|
||||||
}
|
}
|
||||||
|
c.logger.Debug("http request output", "request", "GetVehicleByVIN", "body", respParsed)
|
||||||
|
|
||||||
vData := VehicleData{}
|
vData := VehicleData{}
|
||||||
vdString := respParsed.Path("data").String()
|
vdString := respParsed.Path("data").String()
|
||||||
json.Unmarshal([]byte(vdString), &vData)
|
json.Unmarshal([]byte(vdString), &vData)
|
||||||
|
|
||||||
// fmt.Printf("VEHICLE DATA: %+v\n\n", vData)
|
|
||||||
|
|
||||||
vehicle = &Vehicle{
|
vehicle = &Vehicle{
|
||||||
Vin: vin,
|
Vin: vin,
|
||||||
CarName: vData.VehicleName,
|
CarName: vData.VehicleName,
|
||||||
@ -542,17 +543,23 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
|||||||
if method == "POST" {
|
if method == "POST" {
|
||||||
if json {
|
if json {
|
||||||
// POST > JSON Body
|
// POST > JSON Body
|
||||||
resp, _ = c.httpClient.R().
|
resp, _ = c.httpClient.
|
||||||
|
R().
|
||||||
SetBody(params).
|
SetBody(params).
|
||||||
Post(requestUrl)
|
Post(requestUrl)
|
||||||
} else {
|
} else {
|
||||||
// POST > Form Data
|
// POST > Form Data
|
||||||
resp, _ = c.httpClient.R().
|
resp, _ = c.httpClient.
|
||||||
|
R().
|
||||||
SetFormData(params).
|
SetFormData(params).
|
||||||
Post(requestUrl)
|
Post(requestUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resBytes, _ := io.ReadAll(resp.Body)
|
resBytes, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
c.logger.Error("error while getting body", "error", err.Error())
|
||||||
|
}
|
||||||
|
fmt.Printf("RESP BODY: %s\n", string(resBytes))
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// fmt.Println(err)
|
// fmt.Println(err)
|
||||||
// return
|
// return
|
||||||
|
@ -3,8 +3,9 @@ package mysubaru
|
|||||||
var MOBILE_API_VERSION = "/g2v30"
|
var MOBILE_API_VERSION = "/g2v30"
|
||||||
|
|
||||||
var MOBILE_API_SERVER = map[string]string{
|
var MOBILE_API_SERVER = map[string]string{
|
||||||
"USA": "https://mobileapi.prod.subarucs.com",
|
"USA": "https://mobileapi.prod.subarucs.com",
|
||||||
"CAN": "https://mobileapi.ca.prod.subarucs.com",
|
"CAN": "https://mobileapi.ca.prod.subarucs.com",
|
||||||
|
"TEST": "http://127.0.0.1:56765",
|
||||||
}
|
}
|
||||||
|
|
||||||
var MOBILE_APP = map[string]string{
|
var MOBILE_APP = map[string]string{
|
||||||
@ -116,6 +117,8 @@ var features = map[string]string{
|
|||||||
"g1": "Generation #1",
|
"g1": "Generation #1",
|
||||||
"g2": "Generation #2",
|
"g2": "Generation #2",
|
||||||
"g3": "Generation #3",
|
"g3": "Generation #3",
|
||||||
|
"BDS": "Blind-Spot Detection",
|
||||||
|
"RHSF": "Rear High-Speed Function / Reverse Automatic Braking / Rear Cross-Traffic Alert",
|
||||||
"11.6MMAN": "11.6-inch Infotainment System",
|
"11.6MMAN": "11.6-inch Infotainment System",
|
||||||
"EYESIGHT": "EyeSight Exclusive Advanced Driver-Assist System",
|
"EYESIGHT": "EyeSight Exclusive Advanced Driver-Assist System",
|
||||||
"NAV_TOMTOM": "TomTom Navigation",
|
"NAV_TOMTOM": "TomTom Navigation",
|
||||||
|
100
mysubaru.go
100
mysubaru.go
@ -16,14 +16,14 @@ type Response struct {
|
|||||||
|
|
||||||
// Account .
|
// Account .
|
||||||
type Account struct {
|
type Account struct {
|
||||||
MarketID int `json:"marketId"`
|
MarketID int `json:"marketId"`
|
||||||
CreatedDate int64 `json:"createdDate"`
|
AccountKey int `json:"accountKey"`
|
||||||
FirstName string `json:"firstName"`
|
FirstName string `json:"firstName"`
|
||||||
LastName string `json:"lastName"`
|
LastName string `json:"lastName"`
|
||||||
ZipCode string `json:"zipCode"`
|
ZipCode string `json:"zipCode"`
|
||||||
AccountKey int `json:"accountKey"`
|
ZipCode5 string `json:"zipCode5"`
|
||||||
LastLoginDate time.Time `json:"lastLoginDate"`
|
LastLoginDate int64 `json:"lastLoginDate"`
|
||||||
ZipCode5 string `json:"zipCode5"`
|
CreatedDate int64 `json:"createdDate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Customer .
|
// Customer .
|
||||||
@ -67,48 +67,48 @@ type SessionData struct {
|
|||||||
// Vehicle .
|
// Vehicle .
|
||||||
// "dataName": "vehicle"
|
// "dataName": "vehicle"
|
||||||
type VehicleData struct {
|
type VehicleData struct {
|
||||||
Customer Customer `json:"customer"` // Customer struct
|
Customer Customer `json:"customer"` // Customer struct
|
||||||
UserOemCustID string `json:"userOemCustId"` // CRM-631-HQN48K
|
UserOemCustID string `json:"userOemCustId"` // CRM-631-HQN48K
|
||||||
OemCustID string `json:"oemCustId"` // CRM-631-HQN48K
|
OemCustID string `json:"oemCustId"` // CRM-631-HQN48K
|
||||||
Active bool `json:"active"` // true | false
|
Active bool `json:"active"` // true | false
|
||||||
Email string `json:"email"` // null | email@address.com
|
Email string `json:"email"` // null | email@address.com
|
||||||
FirstName string `json:"firstName"` // null | First Name
|
FirstName string `json:"firstName"` // null | First Name
|
||||||
LastName string `json:"lastName"` // null | Last Name
|
LastName string `json:"lastName"` // null | Last Name
|
||||||
Zip string `json:"zip"` // 12345
|
Zip string `json:"zip"` // 12345
|
||||||
Phone string `json:"phone"` // null | 123-456-7890
|
Phone string `json:"phone"` // null | 123-456-7890
|
||||||
StolenVehicle bool `json:"stolenVehicle"` // true | false
|
StolenVehicle bool `json:"stolenVehicle"` // true | false
|
||||||
VehicleName string `json:"vehicleName"` // Subaru Outback LXT
|
VehicleName string `json:"vehicleName"` // Subaru Outback LXT
|
||||||
Features []string `json:"features"` // "11.6MMAN", "ABS_MIL", "ACCS", "AHBL_MIL", "ATF_MIL", "AWD_MIL", "BSD", "BSDRCT_MIL", "CEL_MIL", "EBD_MIL", "EOL_MIL", "EPAS_MIL", "EPB_MIL", "ESS_MIL", "EYESIGHT", "ISS_MIL", "NAV_TOMTOM", "OPL_MIL", "RAB_MIL", "RCC", "REARBRK", "RES", "RESCC", "RHSF", "RPOI", "RPOIA", "SRH_MIL", "SRS_MIL", "TEL_MIL", "TPMS_MIL", "VDC_MIL", "WASH_MIL", "g2"
|
Features []string `json:"features"` // "11.6MMAN", "ABS_MIL", "ACCS", "AHBL_MIL", "ATF_MIL", "AWD_MIL", "BSD", "BSDRCT_MIL", "CEL_MIL", "EBD_MIL", "EOL_MIL", "EPAS_MIL", "EPB_MIL", "ESS_MIL", "EYESIGHT", "ISS_MIL", "NAV_TOMTOM", "OPL_MIL", "RAB_MIL", "RCC", "REARBRK", "RES", "RESCC", "RHSF", "RPOI", "RPOIA", "SRH_MIL", "SRS_MIL", "TEL_MIL", "TPMS_MIL", "VDC_MIL", "WASH_MIL", "g2"
|
||||||
Vin string `json:"vin"` // 4Y1SL65848Z411439
|
Vin string `json:"vin"` // 4Y1SL65848Z411439
|
||||||
VehicleKey int64 `json:"vehicleKey"` // 3832950
|
VehicleKey int64 `json:"vehicleKey"` // 3832950
|
||||||
Nickname string `json:"nickname"` // Subaru Outback LXT
|
Nickname string `json:"nickname"` // Subaru Outback LXT
|
||||||
ModelName string `json:"modelName"` // Outback
|
ModelName string `json:"modelName"` // Outback
|
||||||
ModelYear string `json:"modelYear"` // 2020
|
ModelYear string `json:"modelYear"` // 2020
|
||||||
ModelCode string `json:"modelCode"` // LDJ
|
ModelCode string `json:"modelCode"` // LDJ
|
||||||
ExtDescrip string `json:"extDescrip"` // Abyss Blue Pearl (ext color)
|
ExtDescrip string `json:"extDescrip"` // Abyss Blue Pearl (ext color)
|
||||||
IntDescrip string `json:"intDescrip"` // Gray (int color)
|
IntDescrip string `json:"intDescrip"` // Gray (int color)
|
||||||
TransCode string `json:"transCode"` // CVT
|
TransCode string `json:"transCode"` // CVT
|
||||||
EngineSize float64 `json:"engineSize"` // 2.4
|
EngineSize float64 `json:"engineSize"` // 2.4
|
||||||
Phev bool `json:"phev"` // null
|
Phev bool `json:"phev"` // null
|
||||||
CachedStateCode string `json:"cachedStateCode"` // NJ
|
CachedStateCode string `json:"cachedStateCode"` // NJ
|
||||||
LicensePlate string `json:"licensePlate"` // NJ
|
LicensePlate string `json:"licensePlate"` // NJ
|
||||||
LicensePlateState string `json:"licensePlateState"` // ABCDEF
|
LicensePlateState string `json:"licensePlateState"` // ABCDEF
|
||||||
SubscriptionStatus string `json:"subscriptionStatus"` // ACTIVE
|
SubscriptionStatus string `json:"subscriptionStatus"` // ACTIVE
|
||||||
SubscriptionFeatures []string `json:"subscriptionFeatures"` // "REMOTE", "SAFETY", "Retail"
|
SubscriptionFeatures []string `json:"subscriptionFeatures"` // "REMOTE", "SAFETY", "Retail"
|
||||||
SubscriptionPlans []string `json:"subscriptionPlans"` // []
|
SubscriptionPlans []string `json:"subscriptionPlans"` // []
|
||||||
VehicleGeoPosition GeoPosition `json:"vehicleGeoPosition"` // GeoPosition struct
|
VehicleGeoPosition GeoPosition `json:"vehicleGeoPosition"` // GeoPosition struct
|
||||||
AccessLevel int `json:"accessLevel"` // -1
|
AccessLevel int `json:"accessLevel"` // -1
|
||||||
VehicleMileage int `json:"vehicleMileage"` // null
|
VehicleMileage int `json:"vehicleMileage"` // null
|
||||||
CrmRightToRepair bool `json:"crmRightToRepair"` // true | false
|
CrmRightToRepair bool `json:"crmRightToRepair"` // true | false
|
||||||
AuthorizedVehicle bool `json:"authorizedVehicle"` // false | true
|
AuthorizedVehicle bool `json:"authorizedVehicle"` // false | true
|
||||||
NeedMileagePrompt bool `json:"needMileagePrompt"` // false | true
|
NeedMileagePrompt bool `json:"needMileagePrompt"` // false | true
|
||||||
RemoteServicePinExist bool `json:"remoteServicePinExist"` // true | false
|
RemoteServicePinExist bool `json:"remoteServicePinExist"` // true | false
|
||||||
NeedEmergencyContactPrompt bool `json:"needEmergencyContactPrompt"` // false | true
|
NeedEmergencyContactPrompt bool `json:"needEmergencyContactPrompt"` // false | true
|
||||||
Show3GSunsetBanner bool `json:"show3gSunsetBanner"` // false | true
|
Show3GSunsetBanner bool `json:"show3gSunsetBanner"` // false | true
|
||||||
Provisioned bool `json:"provisioned"` // true | false
|
Provisioned bool `json:"provisioned"` // true | false
|
||||||
TimeZone time.Location `json:"timeZone"` // America/New_York
|
TimeZone string `json:"timeZone"` // America/New_York
|
||||||
SunsetUpgraded bool `json:"sunsetUpgraded"` // true | false
|
SunsetUpgraded bool `json:"sunsetUpgraded"` // true | false
|
||||||
PreferredDealer string `json:"preferredDealer"` // null |
|
PreferredDealer string `json:"preferredDealer"` // null |
|
||||||
}
|
}
|
||||||
|
|
||||||
// GeoPosition .
|
// GeoPosition .
|
||||||
|
Reference in New Issue
Block a user