Skip to content

Commit

Permalink
re-add compatibleIntegrations to /me
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesReate committed Nov 25, 2024
1 parent abedd81 commit 97f2b46
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions internal/controllers/devices_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ func NewDeviceDefinitionFromGRPC(dd *grpc.GetDeviceDefinitionItemResponse) (serv
for _, style := range dd.DeviceStyles {
rp.Type.SubModels = append(rp.Type.SubModels, style.SubModel)
}
// temporary until mobile app stops using this stuff
if rp.DeviceMake.Name == "Tesla" {
// add only tesla
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "Asia"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "West Asia"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "South America"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "Oceania"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "Europe"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Tesla", "Americas"))
} else if rp.Type.Year > 2005 {
// add hw options, Americas, USA, Europe
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("AutoPi", "Americas"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("AutoPi", "Europe"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Ruptela", "Americas"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Ruptela", "Europe"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Macaron", "Americas"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("Macaron", "Europe"))
}
if rp.DeviceMake.Name != "Tesla" && rp.Type.Year > 2018 {
// add smartcar
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("SmartCar", "Europe"))
rp.CompatibleIntegrations = append(rp.CompatibleIntegrations, buildCompatibleIntegration("SmartCar", "Americas"))
}

return rp, nil
}
Expand All @@ -57,6 +80,47 @@ type DeviceRp struct {
Name string `json:"name"`
}

// buildCompatibleIntegration temporary until mobile app stops using this stuff
func buildCompatibleIntegration(vendor, region string) services.DeviceCompatibility {
dc := services.DeviceCompatibility{}
switch vendor {
case "AutoPi":
dc = services.DeviceCompatibility{
ID: "27qftVRWQYpVDcO5DltO5Ojbjxk",
Type: "Hardware",
Style: "Addon",
}
case "SmartCar":
dc = services.DeviceCompatibility{
ID: "22N2xaPOq2WW2gAHBHd0Ikn4Zob",
Type: "API",
Style: "Webhook",
}
case "Tesla":
dc = services.DeviceCompatibility{
ID: "26A5Dk3vvvQutjSyF0Jka2DP5lg",
Type: "API",
Style: "OEM",
}
case "Ruptela":
dc = services.DeviceCompatibility{
ID: "2lcaMFuCO0HJIUfdq8o780Kx5n3",
Type: "Hardware",
Style: "Addon",
}
case "Macaron":
dc = services.DeviceCompatibility{
ID: "2ULfuC8U9dOqRshZBAi0lMM1Rrx",
Type: "Hardware",
Style: "Addon",
}
}
dc.Vendor = vendor
dc.Region = region

return dc
}

// DeviceCompatibilityFromDB returns list of compatibility representation from device integrations db slice, assumes integration relation loaded
func DeviceCompatibilityFromDB(dbDIS []*grpc.DeviceIntegration) []services.DeviceCompatibility {
if len(dbDIS) == 0 {
Expand Down

0 comments on commit 97f2b46

Please sign in to comment.