go-twitch/api/types/types.go

67 lines
1.4 KiB
Go
Raw Normal View History

2024-02-27 22:13:57 -05:00
package types
import (
"encoding/json"
"time"
)
type Cursor string
func (c Cursor) String() string {
return string(c)
}
func (c *Cursor) UnmarshalText(text []byte) error {
*c = Cursor(string(text))
return nil
}
func (c Cursor) MarshalText() ([]byte, error) {
return []byte(string(c)), nil
}
func (c *Cursor) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
*c = Cursor(s)
return nil
}
func (c Cursor) MarshalJSON() ([]byte, error) {
return json.Marshal(string(c))
}
// Contains the information used to page through the list of results.
// The object is empty if there are no more pages left to page through.
type Pagination struct {
// The cursor used to get the next page of results. Use the cursor to set the requests after query parameter.
Cursor Cursor `json:"cursor"`
}
type DateRange struct {
StartedAt time.Time `json:"started_at"`
EndedAt time.Time `json:"ended_at"`
}
// Content Classification Label
type CCL string
const (
CCLDrugsIntoxication CCL = "DrugsIntoxication"
CCLSexualThemes CCL = "SexualThemes"
CCLViolentGraphic CCL = "ViolentGraphic"
CCLGambling CCL = "Gambling"
CCLProfanityVulgarity CCL = "ProfanityVulgarity"
)
// Sort Order
type SortOrder string
const (
SortOrderOldest SortOrder = "OLDEST"
SortOrderNewest SortOrder = "NEWEST"
)