Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device aliases are a map, not an array #68

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.92.2] - Unreleased
### Fixed
- Parse device aliases as a map, not as an array.

## [0.92.1]- 2024-09-16
### Added
- Add template type support for trigger, thus enabling Mustache templating.
Expand Down
10 changes: 5 additions & 5 deletions client/appengine_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@
}

// Parses data obtained by performing a request device's aliases.
// Returns the list of aliases as an array of strings.
// Returns the list of aliases as a map strings to strings.
func (r ListDeviceAliasesResponse) Parse() (any, error) {
defer r.res.Body.Close()
b, _ := io.ReadAll(r.res.Body)
data := gjson.GetBytes(b, "data.aliases").Array()
aliases := []string{}
for _, v := range data {
aliases = append(aliases, v.Str)
data := gjson.GetBytes(b, "data.aliases").Map()
aliases := map[string]string{}
for k, v := range data {
aliases[k] = v.Str

Check warning on line 234 in client/appengine_data.go

View check run for this annotation

Codecov / codecov/patch

client/appengine_data.go#L231-L234

Added lines #L231 - L234 were not covered by tests
}
return aliases, nil
}
Expand Down
Loading