package rudder import ( "context" "fmt" "net/http" ) type ResourcesService struct { transport *transport } type ResourceBatchItem struct { PlayerID string `json:"playerId"` ID string `json:"id,omitempty"` Data map[string]any `json:"data,omitempty"` Version int64 `json:"version,omitempty"` } type ResourceRowsPage struct { Items []any `json:"items"` Total int `json:"total"` } func (s *ResourcesService) List(ctx context.Context, slug string) (*ResourceRowsPage, error) { var page ResourceRowsPage path := fmt.Sprintf("/resources/%s/rows", slug) if err := s.transport.do(ctx, http.MethodGet, path, nil, nil, &page); err != nil { return nil, err } return &page, nil } func (s *ResourcesService) Create(ctx context.Context, slug string, items []ResourceBatchItem) (*ResourceRowsPage, error) { var page ResourceRowsPage path := fmt.Sprintf("/resources/%s/rows", slug) if err := s.transport.do(ctx, http.MethodPost, path, nil, map[string]any{"items": items}, &page); err != nil { return nil, err } return &page, nil } func (s *ResourcesService) Update(ctx context.Context, slug string, items []ResourceBatchItem) (*ResourceRowsPage, error) { var page ResourceRowsPage path := fmt.Sprintf("/resources/%s/rows", slug) if err := s.transport.do(ctx, http.MethodPatch, path, nil, map[string]any{"items": items}, &page); err != nil { return nil, err } return &page, nil } func (s *ResourcesService) Delete(ctx context.Context, slug string, items []ResourceBatchItem) error { path := fmt.Sprintf("/resources/%s/rows", slug) return s.transport.do(ctx, http.MethodDelete, path, nil, map[string]any{"items": items}, nil) }