models

package
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bundle

type Bundle struct {
	Gamekey     string         `json:"gamekey"`
	Created     HumbleTime     `json:"created"`
	Claimed     bool           `json:"claimed"`
	TpkdDict    map[string]any `json:"tpkd_dict"`
	Details     BundleDetails  `json:"product"`
	Products    []Product      `json:"-"` // Custom unmarshal
	AmountSpent *float64       `json:"amount_spent,omitempty"`
	Currency    *string        `json:"currency,omitempty"`
}

Bundle represents a purchased Humble Bundle

func (*Bundle) ClaimStatus

func (b *Bundle) ClaimStatus() string

ClaimStatus returns the claim status of the bundle

func (*Bundle) ProductKeys

func (b *Bundle) ProductKeys() []ProductKey

ProductKeys extracts all product keys from tpkd_dict

func (*Bundle) TotalSize

func (b *Bundle) TotalSize() uint64

TotalSize returns the sum of all product sizes

func (*Bundle) UnmarshalJSON

func (b *Bundle) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling to skip malformed products

type BundleDetails

type BundleDetails struct {
	MachineName string `json:"machine_name"`
	HumanName   string `json:"human_name"`
}

BundleDetails contains bundle metadata

type BundleMap

type BundleMap map[string]Bundle

BundleMap is a map of gamekey to Bundle

type ChoicePeriod

type ChoicePeriod struct {
	// contains filtered or unexported fields
}

ChoicePeriod represents a Humble Choice period

func NewChoicePeriod

func NewChoicePeriod(s string) ChoicePeriod

func (ChoicePeriod) IsCurrent

func (c ChoicePeriod) IsCurrent() bool

func (ChoicePeriod) String

func (c ChoicePeriod) String() string

type ClaimStatus

type ClaimStatus int

ClaimStatus represents whether a bundle has been claimed

const (
	ClaimStatusAll ClaimStatus = iota
	ClaimStatusYes
	ClaimStatusNo
)

func ParseClaimStatus

func ParseClaimStatus(s string) (ClaimStatus, error)

func (ClaimStatus) String

func (c ClaimStatus) String() string

type ContentChoiceData

type ContentChoiceData struct {
	GameData map[string]GameData `json:"game_data"`
}

ContentChoiceData contains game data for the choice period

type ContentChoiceOptions

type ContentChoiceOptions struct {
	Data            ContentChoiceData `json:"contentChoiceData"`
	Gamekey         *string           `json:"gamekey,omitempty"`
	IsActiveContent bool              `json:"isActiveContent"`
	Title           string            `json:"title"`
}

ContentChoiceOptions contains choice subscription details

type DownloadInfo

type DownloadInfo struct {
	MD5      string      `json:"md5"`
	Format   string      `json:"name"`
	FileSize uint64      `json:"file_size"`
	URL      DownloadURL `json:"url"`
}

DownloadInfo contains download metadata

type DownloadURL

type DownloadURL struct {
	Web        string `json:"web"`
	Bittorrent string `json:"bittorrent"`
}

DownloadURL contains web and torrent URLs

type GameData

type GameData struct {
	Title string `json:"title"`
	Tpkds []Tpkd `json:"tpkds"`
}

GameData represents a game in the choice subscription

type GameKey

type GameKey struct {
	Gamekey string `json:"gamekey"`
}

GameKey represents a simple gamekey response

type HumbleChoice

type HumbleChoice struct {
	Options ContentChoiceOptions `json:"contentChoiceOptions"`
}

HumbleChoice represents a Humble Choice subscription period

type HumbleTime

type HumbleTime struct {
	time.Time
}

HumbleTime is a custom time type that handles Humble Bundle's datetime format

func (*HumbleTime) UnmarshalJSON

func (ht *HumbleTime) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling for HumbleTime

type MatchMode

type MatchMode int

MatchMode represents how keywords should match products

const (
	MatchModeAny MatchMode = iota
	MatchModeAll
)

func ParseMatchMode

func ParseMatchMode(s string) (MatchMode, error)

func (MatchMode) String

func (m MatchMode) String() string

type Product

type Product struct {
	MachineName       string            `json:"machine_name"`
	HumanName         string            `json:"human_name"`
	ProductDetailsURL string            `json:"url"`
	Downloads         []ProductDownload `json:"downloads"`
}

Product represents a product within a bundle

func (*Product) Formats

func (p *Product) Formats() string

Formats returns all formats as a comma-separated string

func (*Product) FormatsAsVec

func (p *Product) FormatsAsVec() []string

FormatsAsVec returns all formats as a slice

func (*Product) NameMatches

func (p *Product) NameMatches(keywords []string, mode MatchMode) bool

NameMatches checks if the product name matches the given keywords

func (*Product) TotalSize

func (p *Product) TotalSize() uint64

TotalSize returns the sum of all download sizes for this product

type ProductDownload

type ProductDownload struct {
	Items []DownloadInfo `json:"download_struct"`
}

ProductDownload represents a downloadable item

func (*ProductDownload) Formats

func (pd *ProductDownload) Formats() string

Formats returns all formats as a comma-separated string

func (*ProductDownload) FormatsAsVec

func (pd *ProductDownload) FormatsAsVec() []string

FormatsAsVec returns all formats as a slice

func (*ProductDownload) TotalSize

func (pd *ProductDownload) TotalSize() uint64

TotalSize returns the sum of all item file sizes

type ProductKey

type ProductKey struct {
	Redeemed  bool
	HumanName string
}

ProductKey represents a redeemable product key

type Tpkd

type Tpkd struct {
	Gamekey        *string `json:"gamekey,omitempty"`
	HumanName      string  `json:"human_name"`
	RedeemedKeyVal *string `json:"redeemed_key_val,omitempty"`
}

Tpkd represents a third-party key distribution

func (*Tpkd) ClaimStatus

func (t *Tpkd) ClaimStatus() string

ClaimStatus returns the claim status of this key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL