package forms

import (
	"time"

	"github.com/shopspring/decimal"
)

type PaymentMethodInput struct {
	PaymentType string `json:"payment_type"`
}

type PaymentMethodType struct {
	TenantID    uint   `json:"tenant_id"`
	PaymentType string `json:"payment_type"`
	Payable     bool   `json:"payable"`
}

type PaymentMeta struct {
	EnlargeMarketplaceMetering bool            `json:"is_aws_cppo_payment"`
	EnlargerDiscount           decimal.Decimal `json:"aws_cppo_discount"`
	IsThirdParty               *bool          `json:"is_third_party"`
}

type PaymentCodeUpdateQuery struct {
	PaymentCode    string  `json:"payment_code"`
	PaymentSubCode *string `json:"payment_sub_code"`
}

type PaymentMethodCreateQuery struct {
	TenantID              uint        `json:"tenant_id"`
	PaymentMethodID       uint        `json:"payment_method_id"`
	PaymentType           string      `json:"payment_type"`
	SetUpPaymentCode      bool        `json:"set_up_payment_code"` // using input payment code
	PaymentCode           string      `json:"payment_code"`
	PaymentSubCode        *string     `json:"payment_sub_code"`
	ManagedBySales        bool        `json:"managed_by_sales"`
	Invoiceable           *bool       `json:"invoiceable"` // default: true
	BindedBillingConfigID *uint       `json:"binded_billing_config_id"`
	PaymentMeta           PaymentMeta `json:"payment_method_meta"`
}

type PaymentMethod struct {
	TenantID              uint        `json:"tenant_id"`
	PaymentMethodID       uint        `json:"payment_method_id"`
	PaymentType           string      `json:"payment_type"`
	PaymentCode           string      `json:"payment_code"`
	PaymentSubCode        *string     `json:"payment_sub_code"`
	Payable               bool        `json:"payable"`
	ManagedBySales        bool        `json:"managed_by_sales"`
	Invoiceable           bool        `json:"invoiceable"`
	InvoiceableAt         *time.Time  `json:"-"`
	Status                string      `json:"status"`
	UnpayableAt           *time.Time  `json:"unpayable_at"`
	BindedBillingConfigID *uint       `json:"binded_billing_config_id"`
	PaymentMeta           PaymentMeta `json:"payment_method_meta"`
}

//Azure

type Beneficiary struct {
	EmailId  string `json:"emailId"`
	ObjectId string `json:"objectId"`
	TenantId string `json:"tenantId"`
	Puid     string `json:"puid"`
}
type Purchaser struct {
	EmailId  string `json:"emailId"`
	ObjectId string `json:"objectId"`
	TenantId string `json:"tenantId"`
	Puid     string `json:"puid"`
}

// SubscriptionDetails represents the details of a subscription.
type SubscriptionDetails struct {
	Id          string      `json:"id"`
	Name        string      `json:"name"`
	PublisherId string      `json:"publisherId"`
	OfferId     string      `json:"offerId"`
	PlanId      string      `json:"planId"`
	Quantity    int         `json:"quantity"`
	Beneficiary Beneficiary `json:"beneficiary"`
	Purchaser   Purchaser   `json:"purchaser"`

	AllowedCustomerOperations []string  `json:"allowedCustomerOperations"`
	SessionMode               string    `json:"sessionMode"`
	IsFreeTrial               bool      `json:"isFreeTrial"`
	AutoRenew                 bool      `json:"autoRenew"`
	IsTest                    bool      `json:"isTest"`
	SandboxType               string    `json:"sandboxType"`
	Created                   time.Time `json:"created"`
	LastModified              string    `json:"lastModified"`
	SaasSubscriptionStatus    string    `json:"saasSubscriptionStatus"`
	Term                      struct {
		StartDate time.Time `json:"startDate"`
		EndDate   time.Time `json:"endDate"`
		TermUnit  string    `json:"termUnit"`
	} `json:"term"`
}
type SubscriptionList struct {
	Subscriptions []SubscriptionDetails `json:"subscriptions"`
	NextLink      string                `json:"@nextLink"`
}

// CreateSubscriptionRequest represents the request body for creating a subscription.
type CreateSubscriptionRequest struct {
	OfferID      string `json:"offerId"`
	PlanID       string `json:"planId"`
	SubscriberID string `json:"subscriberId"`
}

// UpdateSubscriptionRequest represents the request body for updating a subscription.
type UpdateSubscriptionRequest struct {
	Status string `json:"status"`
}
