package card import ( "context" "fmt" "gpt-plus/config" ) // StaticProvider serves cards from a static YAML config list via a card pool. type StaticProvider struct { pool *CardPool } // NewStaticProvider creates a StaticProvider from config card entries. func NewStaticProvider(cards []config.CardEntry, poolCfg PoolConfig) (*StaticProvider, error) { if len(cards) == 0 { return nil, fmt.Errorf("static card provider: no cards configured") } infos := make([]*CardInfo, len(cards)) for i, c := range cards { infos[i] = &CardInfo{ Number: c.Number, ExpMonth: c.ExpMonth, ExpYear: c.ExpYear, CVC: c.CVC, Name: c.Name, Country: c.Country, Currency: c.Currency, Address: c.Address, City: c.City, State: c.State, PostalCode: c.PostalCode, } } pool := NewCardPool(poolCfg) pool.AddCards(infos) return &StaticProvider{pool: pool}, nil } // GetCard returns the next available card from the pool. func (p *StaticProvider) GetCard(ctx context.Context) (*CardInfo, error) { return p.pool.GetCard() } // ReportResult reports the usage outcome. func (p *StaticProvider) ReportResult(ctx context.Context, card *CardInfo, success bool) error { p.pool.ReportResult(card, success) return nil }