Skip to content

Commit

Permalink
Skoda: replace obsolete Skoda api with Enyaq (#19127)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Feb 24, 2025
1 parent 4c73f18 commit 1891a58
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 533 deletions.
1 change: 1 addition & 0 deletions templates/definition/vehicle/skoda-enyaq.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
template: enyaq
covers: ["skoda"]
products:
- brand: Skoda
description:
Expand Down
11 changes: 0 additions & 11 deletions templates/definition/vehicle/skoda.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions util/request/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ type StatusError struct {
resp *http.Response
}

func NewStatusError(resp *http.Response) *StatusError {
return &StatusError{resp: resp}
}

func (e *StatusError) Error() string {
return fmt.Sprintf("unexpected status: %d (%s)", e.resp.StatusCode, http.StatusText(e.resp.StatusCode))
}
Expand Down
84 changes: 0 additions & 84 deletions vehicle/skoda.go

This file was deleted.

91 changes: 0 additions & 91 deletions vehicle/skoda/api.go

This file was deleted.

9 changes: 6 additions & 3 deletions vehicle/skoda/myskoda/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (
"golang.org/x/oauth2"
)

const BaseURI = "https://mysmob.api.connect.skoda-auto.cz/api"
const (
BaseURI = "https://mysmob.api.connect.skoda-auto.cz/api"
AllGen = "connectivityGenerations=MOD1&connectivityGenerations=MOD2&connectivityGenerations=MOD3&connectivityGenerations=MOD4"
)

// API is the Skoda api client
type API struct {
Expand All @@ -34,15 +37,15 @@ func NewAPI(log *util.Logger, ts oauth2.TokenSource) *API {
func (v *API) Vehicles() ([]Vehicle, error) {
var res VehiclesResponse

uri := fmt.Sprintf("%s/v2/garage", BaseURI)
uri := fmt.Sprintf("%s/v2/garage?%s", BaseURI, AllGen)
err := v.GetJSON(uri, &res)

return res.Vehicles, err
}

func (v *API) VehicleDetails(vin string) (Vehicle, error) {
var res Vehicle
uri := fmt.Sprintf("%s/v2/garage/vehicles/%s", BaseURI, vin)
uri := fmt.Sprintf("%s/v2/garage/vehicles/%s?%s", BaseURI, vin, AllGen)
err := v.GetJSON(uri, &res)
return res, err
}
Expand Down
6 changes: 5 additions & 1 deletion vehicle/skoda/myskoda/tokenrefreshservice/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ func (v *Service) Exchange(q url.Values) (*vag.Token, error) {
}

resp, err := v.Post(CodeExchangeURL, request.JSONContent, request.MarshalJSON(data))

if err == nil {
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, request.NewStatusError(resp)
}
}
if err == nil {
json.NewDecoder(resp.Body).Decode(&skTok)
}

Expand Down
24 changes: 0 additions & 24 deletions vehicle/skoda/params.go

This file was deleted.

Loading

0 comments on commit 1891a58

Please sign in to comment.