package rainyun import ( "context" "fmt" "time" "git.yoresee.cc/nightstar/ry/internal/provider" ) type BillingService struct { client *client } func (b *BillingService) Orders(ctx context.Context) ([]provider.Order, error) { type rainyunOrder struct { ID int `json:"id"` ProductName string `json:"product_name"` Amount float64 `json:"amount"` Status string `json:"status"` CreateDate string `json:"create_date"` } var raw []rainyunOrder if err := b.client.get(ctx, "/expense/orders/list", &raw); err != nil { return nil, err } orders := make([]provider.Order, len(raw)) for i, r := range raw { t, _ := time.Parse("2006-01-02 15:04:05", r.CreateDate) orders[i] = provider.Order{ ID: fmt.Sprintf("%d", r.ID), Product: r.ProductName, Amount: r.Amount, Status: r.Status, Created: t, Raw: r, } } return orders, nil }