Skip to content

Commit

Permalink
change CarName to be NullString instead of string (#242)
Browse files Browse the repository at this point in the history
* fix CarName to be NullString instead of string

Co-authored-by: Vincent Barrier <[email protected]>
  • Loading branch information
tobiasehlert and vbarrier authored Sep 22, 2023
1 parent ca0c58b commit 1a3378e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/v1_TeslaMateAPICars.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TeslaMateAPICarsV1(c *gin.Context) {
// Cars struct - child of Data
type Cars struct {
CarID int `json:"car_id"` // smallint
Name string `json:"name"` // text
Name NullString `json:"name"` // text (nullable)
CarDetails CarDetails `json:"car_details"` // struct
CarExterior CarExterior `json:"car_exterior"` // struct
CarSettings CarSettings `json:"car_settings"` // struct
Expand Down
9 changes: 5 additions & 4 deletions src/v1_TeslaMateAPICarsCharges.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func TeslaMateAPICarsChargesV1(c *gin.Context) {
// creating structs for /cars/<CarID>/charges
// Car struct - child of Data
type Car struct {
CarID int `json:"car_id"` // smallint
CarName string `json:"car_name"` // text
CarID int `json:"car_id"` // smallint
CarName NullString `json:"car_name"` // text (nullable)
}
// BatteryDetails struct - child of Charges
type BatteryDetails struct {
Expand Down Expand Up @@ -67,8 +67,9 @@ func TeslaMateAPICarsChargesV1(c *gin.Context) {

// creating required vars
var (
ChargesData []Charges
UnitsLength, UnitsTemperature, CarName string
CarName NullString
ChargesData []Charges
UnitsLength, UnitsTemperature string
)

// calculate offset based on page (page 0 is not possible, since first page is minimum 1)
Expand Down
11 changes: 6 additions & 5 deletions src/v1_TeslaMateAPICarsChargesDetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func TeslaMateAPICarsChargesDetailsV1(c *gin.Context) {
// creating structs for /cars/<CarID>/charges/<ChargeID>
// Car struct - child of Data
type Car struct {
CarID int `json:"car_id"` // smallint
CarName string `json:"car_name"` // text
CarID int `json:"car_id"` // smallint
CarName NullString `json:"car_name"` // text (nullable)
}
// BatteryDetails struct - child of Charges
type BatteryDetails struct {
Expand Down Expand Up @@ -108,9 +108,10 @@ func TeslaMateAPICarsChargesDetailsV1(c *gin.Context) {

// creating required vars
var (
charge Charge
ChargeDetailsData []ChargeDetails
UnitsLength, UnitsTemperature, CarName string
CarName NullString
charge Charge
ChargeDetailsData []ChargeDetails
UnitsLength, UnitsTemperature string
)

// getting data from database
Expand Down
9 changes: 5 additions & 4 deletions src/v1_TeslaMateAPICarsDrives.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func TeslaMateAPICarsDrivesV1(c *gin.Context) {
// creating structs for /cars/<CarID>/drives
// Car struct - child of Data
type Car struct {
CarID int `json:"car_id"` // smallint
CarName string `json:"car_name"` // text
CarID int `json:"car_id"` // smallint
CarName NullString `json:"car_name"` // text (nullable)
}
// OdometerDetails struct - child of Drives
type OdometerDetails struct {
Expand Down Expand Up @@ -82,8 +82,9 @@ func TeslaMateAPICarsDrivesV1(c *gin.Context) {

// creating required vars
var (
DrivesData []Drives
UnitsLength, UnitsTemperature, CarName string
CarName NullString
DrivesData []Drives
UnitsLength, UnitsTemperature string
)

// calculate offset based on page (page 0 is not possible, since first page is minimum 1)
Expand Down
11 changes: 6 additions & 5 deletions src/v1_TeslaMateAPICarsDrivesDetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func TeslaMateAPICarsDrivesDetailsV1(c *gin.Context) {
// creating structs for /cars/<CarID>/drives/<DriveID>
// Car struct - child of Data
type Car struct {
CarID int `json:"car_id"` // smallint
CarName string `json:"car_name"` // text
CarID int `json:"car_id"` // smallint
CarName NullString `json:"car_name"` // text (nullable)
}
// OdometerDetails struct - child of Drives
type OdometerDetails struct {
Expand Down Expand Up @@ -121,9 +121,10 @@ func TeslaMateAPICarsDrivesDetailsV1(c *gin.Context) {

// creating required vars
var (
drive Drive
DriveDetailsData []DriveDetails
UnitsLength, UnitsTemperature, CarName string
CarName NullString
drive Drive
DriveDetailsData []DriveDetails
UnitsLength, UnitsTemperature string
)

// getting data from database
Expand Down
4 changes: 2 additions & 2 deletions src/v1_TeslaMateAPICarsStatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ func (s *statusCache) TeslaMateAPICarsStatusV1(c *gin.Context) {
}
// Cars struct - child of Data
type Car struct {
CarID int `json:"car_id"` // smallint
CarName string `json:"car_name"` // text
CarID int `json:"car_id"` // smallint
CarName NullString `json:"car_name"` // text (nullable)
}
// TeslaMateUnits struct - child of Data
type TeslaMateUnits struct {
Expand Down
4 changes: 2 additions & 2 deletions src/v1_TeslaMateAPICarsUpdates.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func TeslaMateAPICarsUpdatesV1(c *gin.Context) {
// creating structs for /cars/<CarID>/updates
// Car struct - child of Data
type Car struct {
CarID int `json:"car_id"` // smallint
CarName string `json:"car_name"` // text
CarID int `json:"car_id"` // smallint
CarName NullString `json:"car_name"` // text (nullable)
}
// Updates struct - child of Data
type Updates struct {
Expand Down

0 comments on commit 1a3378e

Please sign in to comment.