Files
cloud-services/pkg/foa/foa.go

101 lines
2.8 KiB
Go

package foa
import "time"
type FoaOtaUpdateStatusRequest struct {
OtaID string `json:"ota_id"`
Status string `json:"status"`
NotesToOwner string `json:"notes_to_owner"`
InternalNotes string `json:"internal_notes"`
SuppressEmail bool `json:"suppress_email"`
Vin string `json:"vin"`
AddlData FoaAddlData `json:"addl_data"`
}
type FoaAddlData struct {
FailureReason string `json:"failure_reason,omitempty"`
OwnerAdvice string `json:"owner_advice,omitempty"`
DateScheduled string `json:"date_scheduled,omitempty"`
CancelReason string `json:"cancel_reason,omitempty"`
}
func BuildOtaUpdateStatusInProgressRequest(vin string, updateManifestID int64) FoaOtaUpdateStatusRequest {
var req = FoaOtaUpdateStatusRequest{
Vin: vin,
Status: "IN_PROGRESS",
}
switch updateManifestID {
case 816:
req.NotesToOwner = "Your Ocean is being updated to version 2.2 (1/3)"
case 817, 818, 819:
req.NotesToOwner = "Your Ocean is being updated to version 2.2 (2/3)"
case 820:
req.NotesToOwner = "Your Ocean is being updated to version 2.2 (3/3)"
}
return req
}
func BuildOtaUpdateStatusSuccessRequest(vin string, updateManifestID int64) FoaOtaUpdateStatusRequest {
var req = FoaOtaUpdateStatusRequest{
Vin: vin,
Status: "COMPLETE_SUCCESSFUL",
}
switch updateManifestID {
case 816:
req.NotesToOwner = "Your Ocean has successfully been updated to version 2.2 (1/3)"
case 817, 818, 819:
req.NotesToOwner = "Your Ocean has successfully been updated to version 2.2 (2/3)"
case 820:
req.NotesToOwner = "Your Ocean has successfully been updated to version 2.2 (3/3)"
}
return req
}
func BuildOtaUpdateStatusFailedRequest(vin string, updateManifestID int64, info string) FoaOtaUpdateStatusRequest {
var req = FoaOtaUpdateStatusRequest{
Vin: vin,
Status: "COMPLETE_FAILED",
AddlData: FoaAddlData{
FailureReason: "Update failed because of an error",
OwnerAdvice: info,
},
}
switch updateManifestID {
case 816:
req.NotesToOwner = "There was an error updating your Ocean to version 2.2 (1/3)"
case 817, 818, 819:
req.NotesToOwner = "There was an error updating your Ocean to version 2.2 (2/3)"
case 820:
req.NotesToOwner = "There was an error updating your Ocean to version 2.2 (3/3)"
}
return req
}
func BuildOtaUpdateStatusCanceledRequest(vin string, updateManifestID int64, info string) FoaOtaUpdateStatusRequest {
var req = FoaOtaUpdateStatusRequest{
Vin: vin,
Status: "CANCELLED",
AddlData: FoaAddlData{
CancelReason: info,
DateScheduled: time.Now().Local().String(),
},
}
switch updateManifestID {
case 816:
req.NotesToOwner = "Update 2.2 (1/3) to your Ocean was canceled"
case 817, 818, 819:
req.NotesToOwner = "Update 2.2 (2/3) to your Ocean was canceled"
case 820:
req.NotesToOwner = "Update 2.2 (3/3) to your Ocean was canceled"
}
return req
}