Fix ID fields to accept both JSON strings and numbers

The Yandex Music API returns IDs as both JSON strings and numbers depending
on the endpoint. Added JSONID custom type in internal/models/base.go that
implements json.Unmarshaler to accept both formats and store as string.

Changed ID fields from string to JSONID:
- Track.ID, Major.ID, TrackLyricsInfo.ID (track.go)
- Album.ID, TrailerInfo.TrackID, TrailerInfo.AlbumID (album.go)

Updated example to convert JSONID to string when passing to client methods.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
MrixsandClaude Code committed 2026-10-18 10:21:58 +03:00
1 parent 0456ca0665
commit 5535d2a941
4 files changed
+49 -20

No files matched your search

+1 -1
View File
@@ -57,7 +57,7 @@ func main() {
// Example: Get track by ID (if we have results)
if len(tracks) > 0 {
fmt.Println("\n--- Getting track details ---")
track, err := client.GetTrack(ctx, tracks[0].ID)
track, err := client.GetTrack(ctx, string(tracks[0].ID))
if err != nil {
log.Printf("Get track failed: %v", err)
} else {