package models

import "time"

type CurrencyKey = string

type CurrencyList struct {
	ID         string        `json:"id" bson:"_id,omitempty"`
	Name       string        `json:"name" bson:"name"`
	Currencies []CurrencyKey `json:"currencies" bson:"currencies"`
	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"`
}

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

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

	return receiver
}

const (
	DefaultCurrencyListName             = "currency_list"
	InternalCurrencyKey     CurrencyKey = "RUB"
)

type TranslateCurrency struct {
	Money int64       `json:"value"`
	From  CurrencyKey `json:"currencyFrom"`
	To    CurrencyKey `json:"currencyTo"`
}

type CurrencyClientResponse[T any] struct {
	Success bool `json:"success"`
	Message T    `json:"message"`
}

type ChangeCurrency struct {
	Currency CurrencyKey `json:"currency"`
}
