Skip to content

Commit

Permalink
fix CarName to be NullString instead of string
Browse files Browse the repository at this point in the history
Co-Authored-By: Vincent Barrier <[email protected]>
  • Loading branch information
tobiasehlert and vbarrier committed Sep 22, 2023
1 parent ca0c58b commit e4ff878
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
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 e4ff878

Please sign in to comment.