package commerce

import "time"

type AvailableCouponResponse struct {
	ID                int64   `json:"id"`
	Description       *string `json:"description"`
	Type              string  `json:"type"`
	Value             int     `json:"value"`
	ThresholdAmount   int     `json:"threshold_amount"`
	MaxDiscountAmount int     `json:"max_discount_amount"`
	DiscountLevel     string  `json:"discount_level"`
	Scope             string  `json:"scope"`
	ExpiresAt         *string `json:"expires_at"`
}

type AvailableCouponsResponse struct {
	Items         []AvailableCouponResponse `json:"items"`
	AgentDisabled bool                      `json:"agent_disabled"`
}

type CouponApplicationResponse struct {
	Description       *string       `json:"description"`
	IssuerType        *string       `json:"issuer_type"`
	IssuerUserID      *int64        `json:"issuer_user_id"`
	Type              string        `json:"type"`
	Value             int           `json:"value"`
	DiscountLevel     string        `json:"discount_level"`
	TargetCartItemID  *int64        `json:"target_cart_item_id"`
	TargetProductID   *int64        `json:"target_product_id"`
	OrderAmount       int           `json:"order_amount"`
	EligibleAmount    int           `json:"eligible_amount"`
	DiscountAmount    int           `json:"discount_amount"`
	ItemDiscounts     map[int64]int `json:"item_discounts"`
	MaxDiscountAmount int           `json:"max_discount_amount"`
	MinQuantity       int           `json:"min_quantity"`
	FinalAmount       *int          `json:"final_amount,omitempty"`
}

type CouponTargetOption struct {
	CartItemID     int64   `json:"cart_item_id"`
	ProductID      int64   `json:"product_id"`
	ProductName    string  `json:"product_name"`
	SKU            *string `json:"sku"`
	Cycle          string  `json:"cycle"`
	Quantity       int     `json:"quantity"`
	ItemTotal      int     `json:"item_total"`
	DiscountAmount int     `json:"discount_amount"`
	FinalAmount    int     `json:"final_amount"`
}

type CouponPreviewResponse struct {
	TotalAmount             int                        `json:"total_amount"`
	CouponDiscountAmount    int                        `json:"coupon_discount_amount"`
	PointsDiscountAmount    int                        `json:"points_discount_amount"`
	DiscountAmount          int                        `json:"discount_amount"`
	FinalAmount             int                        `json:"final_amount"`
	ActualUsePoints         int                        `json:"actual_use_points"`
	Coupon                  *CouponApplicationResponse `json:"coupon"`
	RequiresTargetSelection bool                       `json:"requires_target_selection"`
	TargetOptions           []CouponTargetOption       `json:"target_options"`
}

type CheckoutResponse struct {
	OrderID              int64                      `json:"order_id"`
	OutOrderNo           string                     `json:"out_order_no"`
	TotalAmount          int                        `json:"total_amount"`
	DiscountAmount       int                        `json:"discount_amount"`
	CouponDiscountAmount int                        `json:"coupon_discount_amount"`
	PointsDiscountAmount int                        `json:"points_discount_amount"`
	PaidAmount           int                        `json:"paid_amount"`
	Coupon               *CouponApplicationResponse `json:"coupon"`
	InstanceCount        int                        `json:"instance_count"`
}

type OrderListItemResponse struct {
	ID             int64     `json:"id"`
	OutOrderNo     string    `json:"out_order_no"`
	Status         string    `json:"status"`
	TotalAmount    int       `json:"total_amount"`
	DiscountAmount int       `json:"discount_amount"`
	CreatedAt      time.Time `json:"created_at"`
}

type OrderInstanceResponse struct {
	ID        int64      `json:"id"`
	Status    string     `json:"status"`
	MainIP    *string    `json:"main_ip"`
	Hostname  *string    `json:"hostname"`
	ExpiresAt *time.Time `json:"expires_at"`
}

type OrderDetailResponse struct {
	ID             int64                   `json:"id"`
	OutOrderNo     string                  `json:"out_order_no"`
	Status         string                  `json:"status"`
	TotalAmount    int                     `json:"total_amount"`
	DiscountAmount int                     `json:"discount_amount"`
	ItemsSnapshot  []any                   `json:"items_snapshot"`
	CreatedAt      time.Time               `json:"created_at"`
	Instances      []OrderInstanceResponse `json:"instances"`
}
