mirror of
https://github.com/tobiasehlert/teslamateapi.git
synced 2026-02-27 09:54:18 +08:00
Update Charges API to Allow Valid Empty Response
API should fail gracefully if an empty response is sent. Example reason: an API consumer should be able to traverse the pages until empty data is returned. Note: currently this is not possible, since a generic error will be thrown if the data set is empty (including on a fresh install of TeslaMate) or if there is an invalid charge in the response. It's impossible to know if all data points were traversed or if an error exists on a single charge (See: https://github.com/tobiasehlert/teslamateapi/issues/43)
This commit is contained in:
@@ -179,6 +179,11 @@ func TeslaMateAPICarsChargesV1(c *gin.Context) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// if no errors, but ChargeData is empty, return a valid response with an empty set
|
||||
if len(ChargeData) == 0 {
|
||||
ValidResponse = true
|
||||
}
|
||||
|
||||
//
|
||||
// build the data-blob
|
||||
|
||||
Reference in New Issue
Block a user