Skip to content

Commit

Permalink
Mercedes: use user instead of account
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed May 15, 2024
1 parent 606cd8f commit c3b48b0
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions vehicle/mercedes.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ func init() {
// NewMercedesFromConfig creates a new vehicle
func NewMercedesFromConfig(other map[string]interface{}) (api.Vehicle, error) {
cc := struct {
embed `mapstructure:",squash"`
Tokens Tokens
Account string
VIN string
Cache time.Duration
Region string
embed `mapstructure:",squash"`
Tokens Tokens
User string
Account_ string `mapstructure:"account"` // TODO deprecated
VIN string
Cache time.Duration
Region string
}{
Cache: interval,
}
Expand All @@ -40,8 +41,12 @@ func NewMercedesFromConfig(other map[string]interface{}) (api.Vehicle, error) {
return nil, err
}

if cc.User == "" && cc.Account_ != "" {
cc.User = cc.Account_
}

log := util.NewLogger("mercedes").Redact(cc.Tokens.Access, cc.Tokens.Refresh)
identity, err := mercedes.NewIdentity(log, token, cc.Account, cc.Region)
identity, err := mercedes.NewIdentity(log, token, cc.User, cc.Region)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit c3b48b0

Please sign in to comment.