package models

import "time"

type History struct {
	ID         string     `json:"id" bson:"_id,omitempty"`
	UserID     string     `json:"userId" bson:"userId"`
	Comment    string     `json:"comment" bson:"comment"`
	Key        string     `json:"key" bson:"key"`
	RawDetails RawDetails `json:"rawDetails" bson:"rawDetails"`
	Deleted    bool       `json:"isDeleted" bson:"isDeleted"`
	CreatedAt  time.Time  `json:"createdAt" bson:"createdAt"`
	UpdatedAt  time.Time  `json:"updatedAt" bson:"updatedAt"`
	DeletedAt  *time.Time `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`
	Version    uint32     `json:"version" bson:"version"`
}

type TariffID struct {
	ID string `json:"id" bson:"_id"`
}

type ReportHistory struct {
	ID         string     `json:"id" bson:"_id,omitempty"`
	UserID     string     `json:"userId" bson:"userId"`
	Comment    string     `json:"comment" bson:"comment"`
	Key        string     `json:"key" bson:"key"`
	RawDetails RawDetails `json:"rawDetails" bson:"rawDetails"`
	Deleted    bool       `json:"isDeleted" bson:"isDeleted"`
	CreatedAt  time.Time  `json:"createdAt" bson:"createdAt"`
	UpdatedAt  time.Time  `json:"updatedAt" bson:"updatedAt"`
	DeletedAt  *time.Time `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`
}

type RawDetails struct {
	Tariffs []Tariff `json:"tariffs" bson:"tariffs"`
	Price   int64    `json:"price" bson:"price"`
	Comment string   `json:"comment" bson:"comment"`
}

func (receiver *History) Sanitize() *History {
	now := time.Now()

	receiver.ID = ""
	receiver.CreatedAt = now
	receiver.UpdatedAt = now
	receiver.DeletedAt = nil
	receiver.Deleted = false
	receiver.Version = mongoVersion

	return receiver
}

type CustomerHistoryKey string

const (
	CustomerHistoryKeyReplenish = "replenishWallet"
	CustomerHistoryKeyPayCart   = "payCart"
)
