79 lines
2.0 KiB
Go
79 lines
2.0 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"gitea.mrixs.me/Mrixs/yandex-music-api-go/internal/models"
|
|
)
|
|
|
|
// GetConcerts gets 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.Sprintf("%d", page)
|
|
}
|
|
if pageSize > 0 {
|
|
params["page_size"] = fmt.Sprintf("%d", pageSize)
|
|
}
|
|
|
|
var result models.ConcertFeed
|
|
if err := c.request.Get(ctx, "/concerts", params, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|
|
|
|
// GetConcertFeed gets concert 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
|
|
func (c *Client) GetConcertInfo(ctx context.Context, concertID string) (*models.ConcertInfo, error) {
|
|
params := map[string]string{
|
|
"concert_id": concertID,
|
|
}
|
|
|
|
var result models.ConcertInfo
|
|
if err := c.request.Get(ctx, "/concerts/info", params, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|
|
|
|
// GetConcertLocations gets concert 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 tabs
|
|
func (c *Client) GetConcertTabs(ctx context.Context, concertID string) ([]*models.ConcertTabConfig, error) {
|
|
params := map[string]string{
|
|
"concert_id": concertID,
|
|
}
|
|
|
|
var result []models.ConcertTabConfig
|
|
if err := c.request.Get(ctx, "/concerts/tabs", params, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
tabs := make([]*models.ConcertTabConfig, len(result))
|
|
for i := range result {
|
|
result[i].SetClient(c)
|
|
tabs[i] = &result[i]
|
|
}
|
|
return tabs, nil
|
|
}
|