go-twitch/api/types/types.go

116 lines
2.6 KiB
Go
Raw Permalink 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"`
}
// Sort Order
type SortOrder string
const (
SortOrderOldest SortOrder = "OLDEST"
SortOrderNewest SortOrder = "NEWEST"
)
2024-02-27 22:26:57 -05:00
// Currency Amount
type CurrencyAmount struct {
// The monetary amount.
// The amount is specified in the currencys minor unit.
// For example, the minor units for USD is cents, so if the amount is $5.50 USD, value is set to 550.
Value int `json:"value"`
// The number of decimal places used by the currency. For example, USD uses two decimal places.
// Use this number to translate value from minor units to major units by using the formula:
//
// value / 10^decimal_places
DecimalPlaces int `json:"decimal_places"`
// The ISO-4217 three-letter currency code that identifies the type of currency in value.
Currency string `json:"currency"`
}
2024-02-28 10:30:20 -05:00
type AccentColor string
const (
AccentColorPrimary AccentColor = "primary"
AccentColorBlue AccentColor = "blue"
AccentColorGreen AccentColor = "green"
AccentColorOrange AccentColor = "orange"
AccentColorPurple AccentColor = "purple"
)
type Locale string
const (
LocaleBgBg = "bg-BG"
LocaleCsCz = "cs-CZ"
LocaleDaDk = "da-DK"
LocaleDeDe = "de-DE"
LocaleElGr = "el-GR"
LocaleEnGb = "en-GB"
LocaleEnUs = "en-US"
LocaleEsEs = "es-ES"
LocaleEsMx = "es-MX"
LocaleFiFi = "fi-FI"
LocaleFrFr = "fr-FR"
LocaleHuHu = "hu-HU"
LocaleItIt = "it-IT"
LocaleJaJp = "ja-JP"
LocaleKoKr = "ko-KR"
LocaleNlNl = "nl-NL"
LocalePlPl = "pl-PL"
LocalePtBt = "pt-BT"
LocalePtPt = "pt-PT"
LocaleRoRo = "ro-RO"
LocaleRuRu = "ru-RU"
LocaleSkSk = "sk-SK"
LocaleSvSe = "sv-SE"
LocaleThTh = "th-TH"
LocaleTrTr = "tr-TR"
LocaleViVn = "vi-VN"
LocaleZhCn = "zh-CN"
LocaleZhTw = "zh-TW"
)