go-twitch/api/types/types.go

116 lines
2.6 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"
)
// 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"`
}
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"
)