package dto

import "time"

type BillingSummaryResponse struct {
	OrganizationID        string    `json:"organizationId"`
	CreditUnit            string    `json:"creditUnit"`
	AvailableCreditAtoms  int64     `json:"availableCreditAtoms"`
	HeldCreditAtoms       int64     `json:"heldCreditAtoms"`
	ConsumedCreditAtoms   int64     `json:"consumedCreditAtoms"`
	TodaySpendCreditAtoms int64     `json:"todaySpendCreditAtoms"`
	MonthSpendCreditAtoms int64     `json:"monthSpendCreditAtoms"`
	UpdatedAt             time.Time `json:"updatedAt"`
}

type BillingLedgerItemResponse struct {
	ID               string    `json:"id"`
	Type             string    `json:"type"`
	CreditUnit       string    `json:"creditUnit"`
	CreditDeltaAtoms int64     `json:"creditDeltaAtoms"`
	Description      string    `json:"description"`
	PaymentOrderID   string    `json:"paymentOrderId,omitempty"`
	OccurredAt       time.Time `json:"occurredAt"`
}

type BillingLedgerPageResponse struct {
	Items      []BillingLedgerItemResponse `json:"items"`
	NextCursor string                      `json:"nextCursor,omitempty"`
}

type BillingModelUsageItemResponse struct {
	ModelReference      string `json:"modelReference"`
	RequestCount        int64  `json:"requestCount"`
	CreditUnit          string `json:"creditUnit"`
	ConsumedCreditAtoms int64  `json:"consumedCreditAtoms"`
}

type BillingModelUsageResponse struct {
	Month                    string                          `json:"month"`
	CreditUnit               string                          `json:"creditUnit"`
	TotalRequestCount        int64                           `json:"totalRequestCount"`
	TotalConsumedCreditAtoms int64                           `json:"totalConsumedCreditAtoms"`
	Items                    []BillingModelUsageItemResponse `json:"items"`
}

type BillingPaymentOrderResponse struct {
	ID                 string     `json:"id"`
	OutTradeNo         string     `json:"outTradeNo"`
	Provider           string     `json:"provider"`
	Status             string     `json:"status"`
	CreditUnit         string     `json:"creditUnit,omitempty"`
	CreditAmount       int64      `json:"creditAmount"`
	Currency           string     `json:"currency"`
	PayableAmountCents int64      `json:"payableAmountCents"`
	ExpiresAt          time.Time  `json:"expiresAt"`
	CreatedAt          time.Time  `json:"createdAt"`
	PaidAt             *time.Time `json:"paidAt,omitempty"`
	ClosedAt           *time.Time `json:"closedAt,omitempty"`
}

type BillingPaymentOrderPageResponse struct {
	Items      []BillingPaymentOrderResponse `json:"items"`
	NextCursor string                        `json:"nextCursor,omitempty"`
}

type HostedModelPricingTierRatesResponse struct {
	InputTokensCreditAtomsPerMillionTokens    int64 `json:"inputTokensCreditAtomsPerMillionTokens"`
	CacheReadInputCreditAtomsPerMillionTokens int64 `json:"cacheReadInputCreditAtomsPerMillionTokens"`
	OutputCreditAtomsPerMillionTokens         int64 `json:"outputCreditAtomsPerMillionTokens"`
}

type HostedModelPricingTierResponse struct {
	ID               string                              `json:"id"`
	MinContextTokens int64                               `json:"minContextTokens"`
	MaxContextTokens *int64                              `json:"maxContextTokens"`
	Rates            HostedModelPricingTierRatesResponse `json:"rates"`
}

type HostedPricingOverrideResponse struct {
	ID                        string     `json:"id"`
	HostedModelID             string     `json:"hostedModelId"`
	ScopeType                 string     `json:"scopeType"`
	ScopeID                   string     `json:"scopeId,omitempty"`
	BasePricingVersionID      string     `json:"basePricingVersionId"`
	EffectivePricingVersionID string     `json:"effectivePricingVersionId"`
	OverrideType              string     `json:"overrideType"`
	DisplayLabel              string     `json:"displayLabel,omitempty"`
	Priority                  int        `json:"priority"`
	EffectiveFrom             *time.Time `json:"effectiveFrom,omitempty"`
	EffectiveTo               *time.Time `json:"effectiveTo,omitempty"`
	Status                    string     `json:"status"`
}

type BillingHostedModelPricingResponse struct {
	ID                                            string                           `json:"id"`
	ModelReference                                string                           `json:"modelReference"`
	HostedModelID                                 string                           `json:"hostedModelId,omitempty"`
	DisplayName                                   string                           `json:"displayName"`
	PricingVersionID                              string                           `json:"pricingVersionId,omitempty"`
	EffectivePricingVersionID                     string                           `json:"effectivePricingVersionId,omitempty"`
	PricingFormulaVersion                         string                           `json:"pricingFormulaVersion,omitempty"`
	BillableDimensions                            []string                         `json:"billableDimensions,omitempty"`
	ContextTiers                                  []HostedModelPricingTierResponse `json:"contextTiers,omitempty"`
	InputCreditAtomsPerMillionTokens              *int64                           `json:"inputCreditAtomsPerMillionTokens,omitempty"`
	CacheReadInputCreditAtomsPerMillionTokens     *int64                           `json:"cacheReadInputCreditAtomsPerMillionTokens,omitempty"`
	OutputCreditAtomsPerMillionTokens             *int64                           `json:"outputCreditAtomsPerMillionTokens,omitempty"`
	BasePricingVersionID                          string                           `json:"basePricingVersionId,omitempty"`
	BasePricingFormulaVersion                     string                           `json:"basePricingFormulaVersion,omitempty"`
	BaseBillableDimensions                        []string                         `json:"baseBillableDimensions,omitempty"`
	BaseContextTiers                              []HostedModelPricingTierResponse `json:"baseContextTiers,omitempty"`
	BaseInputCreditAtomsPerMillionTokens          *int64                           `json:"baseInputCreditAtomsPerMillionTokens,omitempty"`
	BaseCacheReadInputCreditAtomsPerMillionTokens *int64                           `json:"baseCacheReadInputCreditAtomsPerMillionTokens,omitempty"`
	BaseOutputCreditAtomsPerMillionTokens         *int64                           `json:"baseOutputCreditAtomsPerMillionTokens,omitempty"`
	PricingOverride                               *HostedPricingOverrideResponse   `json:"pricingOverride,omitempty"`
}

type BillingPricingResponse struct {
	CreditUnit           string                              `json:"creditUnit"`
	Currency             string                              `json:"currency"`
	CreditAmountPerCNY   int64                               `json:"creditAmountPerCny"`
	CreditAtomsPerCredit int64                               `json:"creditAtomsPerCredit"`
	CreditAtomsPerCNY    int64                               `json:"creditAtomsPerCny"`
	RechargePresets      []int64                             `json:"rechargePresets"`
	CustomMinCredits     int64                               `json:"customMinCredits"`
	HostedModels         []BillingHostedModelPricingResponse `json:"hostedModels"`
}

type BillingCreditRechargeOrderCreateRequest struct {
	CreditAmount int64 `json:"creditAmount"`
}

type BillingCreditRechargeOrderResponse struct {
	OrderID            string     `json:"orderId"`
	OutTradeNo         string     `json:"outTradeNo"`
	Status             string     `json:"status"`
	CreditUnit         string     `json:"creditUnit"`
	CreditAmount       int64      `json:"creditAmount"`
	Currency           string     `json:"currency"`
	PayableAmountCents int64      `json:"payableAmountCents"`
	PaymentURL         string     `json:"paymentUrl,omitempty"`
	ExpiresAt          time.Time  `json:"expiresAt"`
	PaidAt             *time.Time `json:"paidAt,omitempty"`
	ClosedAt           *time.Time `json:"closedAt,omitempty"`
}

type BillingSeatPlanResponse struct {
	ID                   string `json:"id"`
	PlanKey              string `json:"planKey"`
	Name                 string `json:"name"`
	BillingPeriod        string `json:"billingPeriod"`
	UnitPriceCents       int64  `json:"unitPriceCents"`
	Currency             string `json:"currency"`
	ManagedAgentsPerSeat int64  `json:"managedAgentsPerSeat"`
	MinSeatQuantity      int    `json:"minSeatQuantity"`
	MaxSeatQuantity      int    `json:"maxSeatQuantity"`
	SelfServiceEnabled   bool   `json:"selfServiceEnabled"`
	Status               string `json:"status"`
}

type BillingSeatPlansResponse struct {
	Items []BillingSeatPlanResponse `json:"items"`
}

type BillingSeatSummaryResponse struct {
	OrganizationID         string     `json:"organizationId"`
	PlanKey                string     `json:"planKey"`
	BillingPeriod          string     `json:"billingPeriod,omitempty"`
	Paid                   bool       `json:"paid"`
	SubscriptionStatus     string     `json:"subscriptionStatus,omitempty"`
	HumanSeatLimit         int64      `json:"humanSeatLimit"`
	FreeHumanSeatLimit     int64      `json:"freeHumanSeatLimit"`
	PaidHumanSeatLimit     int64      `json:"paidHumanSeatLimit"`
	GiftHumanSeatLimit     int64      `json:"giftHumanSeatLimit"`
	NextGrantExpiresAt     *time.Time `json:"nextGrantExpiresAt,omitempty"`
	CurrentHumanSeats      int64      `json:"currentHumanSeats"`
	HumanSeatsOverLimit    bool       `json:"humanSeatsOverLimit"`
	OrganizationAgentLimit int64      `json:"organizationAgentLimit"`
	CurrentAgents          int64      `json:"currentAgents"`
	AgentsOverLimit        bool       `json:"agentsOverLimit"`
	ManagedAgentsPerSeat   int64      `json:"managedAgentsPerSeat"`
	CurrentPeriodStart     *time.Time `json:"currentPeriodStart,omitempty"`
	CurrentPeriodEnd       *time.Time `json:"currentPeriodEnd,omitempty"`
}

type BillingSeatSubscriptionResponse struct {
	OrganizationID               string    `json:"organizationId"`
	Status                       string    `json:"status"`
	PlanKey                      string    `json:"planKey"`
	BillingPeriod                string    `json:"billingPeriod"`
	SeatQuantity                 int       `json:"seatQuantity"`
	ManagedAgentsPerSeatSnapshot int64     `json:"managedAgentsPerSeatSnapshot"`
	MaxHumanSeatsSnapshot        int       `json:"maxHumanSeatsSnapshot"`
	UnitPriceCentsSnapshot       int64     `json:"unitPriceCentsSnapshot"`
	Currency                     string    `json:"currency"`
	CurrentPeriodStart           time.Time `json:"currentPeriodStart"`
	CurrentPeriodEnd             time.Time `json:"currentPeriodEnd"`
	CreatedAt                    time.Time `json:"createdAt"`
	UpdatedAt                    time.Time `json:"updatedAt"`
}

type BillingSeatSubscriptionEnvelopeResponse struct {
	Subscription *BillingSeatSubscriptionResponse `json:"subscription"`
}

type BillingSeatOrderCreateRequest struct {
	OrderType         string `json:"orderType"`
	ToPlanKey         string `json:"toPlanKey,omitempty"`
	BillingPeriod     string `json:"billingPeriod,omitempty"`
	SeatQuantityAfter int    `json:"seatQuantityAfter,omitempty"`
}

type BillingSeatOrderResponse struct {
	OrderID            string     `json:"orderId"`
	OrderType          string     `json:"orderType"`
	Status             string     `json:"status"`
	FromPlanKey        *string    `json:"fromPlanKey,omitempty"`
	ToPlanKey          *string    `json:"toPlanKey,omitempty"`
	BillingPeriod      string     `json:"billingPeriod"`
	SeatQuantityBefore int        `json:"seatQuantityBefore"`
	SeatQuantityAfter  int        `json:"seatQuantityAfter"`
	SeatDelta          int        `json:"seatDelta"`
	AmountCents        int64      `json:"amountCents"`
	Currency           string     `json:"currency"`
	Provider           string     `json:"provider"`
	ProviderOrderID    string     `json:"providerOrderId"`
	PaymentStatus      string     `json:"paymentStatus"`
	PaymentURL         string     `json:"paymentUrl,omitempty"`
	ExpiresAt          time.Time  `json:"expiresAt"`
	PaidAt             *time.Time `json:"paidAt,omitempty"`
	ClosedAt           *time.Time `json:"closedAt,omitempty"`
	CancelledByUserID  *string    `json:"cancelledByUserId,omitempty"`
	SettledAt          *time.Time `json:"settledAt,omitempty"`
	AppliedAt          *time.Time `json:"appliedAt,omitempty"`
	CreatedAt          time.Time  `json:"createdAt"`
	UpdatedAt          time.Time  `json:"updatedAt"`
}

type BillingSeatOrderListResponse struct {
	Items []BillingSeatOrderResponse `json:"items"`
}

type BillingHistoryItemResponse struct {
	ProductType       string     `json:"productType"`
	SourceOrderID     string     `json:"sourceOrderId"`
	ProviderPaymentID string     `json:"providerPaymentId"`
	Status            string     `json:"status"`
	AmountCents       int64      `json:"amountCents"`
	Currency          string     `json:"currency"`
	CreatedAt         time.Time  `json:"createdAt"`
	PaidAt            *time.Time `json:"paidAt,omitempty"`
}

type BillingHistoryResponse struct {
	Items []BillingHistoryItemResponse `json:"items"`
}
