- Document all exported types, functions, methods, and constants across 52 files - Add package-level doc comments to client, models, utils, and ynison packages - Document HTTP method and endpoint path for each API client method - Document model struct fields and DeJSON/DeList/ToJSON/ToMap methods - Fix duplicate package doc comment in internal/models/base.go Co-Authored-By: Claude Code <noreply@anthropic.com>
66 lines
2.0 KiB
Go
66 lines
2.0 KiB
Go
// Package client provides methods for interacting with Yandex Music API endpoints.
|
|
package client
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"gitea.mrixs.me/Mrixs/yandex-music-api-go/internal/models"
|
|
)
|
|
|
|
// GetConcerts gets concerts with pagination (GET /concerts).
|
|
func (c *Client) GetConcerts(ctx context.Context, page, pageSize int) (*models.ConcertFeed, error) {
|
|
params := map[string]string{
|
|
"page": "1",
|
|
"page_size": "20",
|
|
}
|
|
if page > 0 {
|
|
params["page"] = fmt.Sprint(page)
|
|
}
|
|
if pageSize > 0 {
|
|
params["page_size"] = fmt.Sprint(pageSize)
|
|
}
|
|
|
|
var result models.ConcertFeed
|
|
if err := c.request.Get(ctx, "/concerts", params, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|
|
|
|
// GetConcertFeed gets the concert feed (GET /concerts/feed).
|
|
func (c *Client) GetConcertFeed(ctx context.Context) (*models.ConcertFeed, error) {
|
|
var result models.ConcertFeed
|
|
if err := c.request.Get(ctx, "/concerts/feed", nil, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|
|
|
|
// GetConcertInfo gets concert info by ID (GET /concerts/{concertID}/info).
|
|
func (c *Client) GetConcertInfo(ctx context.Context, concertID string) (*models.ConcertInfo, error) {
|
|
var result models.ConcertInfo
|
|
if err := c.request.Get(ctx, fmt.Sprintf("/concerts/%s/info", concertID), nil, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|
|
|
|
// GetConcertLocations gets concert locations (GET /concerts/locations).
|
|
func (c *Client) GetConcertLocations(ctx context.Context) (*models.ConcertLocations, error) {
|
|
var result models.ConcertLocations
|
|
if err := c.request.Get(ctx, "/concerts/locations", nil, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|
|
|
|
// GetConcertTabs gets concert tab configuration (GET /concerts/tab-config).
|
|
func (c *Client) GetConcertTabs(ctx context.Context) (*models.ConcertTabConfig, error) {
|
|
var result models.ConcertTabConfig
|
|
if err := c.request.Get(ctx, "/concerts/tab-config", nil, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|