package model

import (
	"strings"

	"github.com/tech/sendico/pkg/db/storable"
	"github.com/tech/sendico/pkg/mservice"
)

// ChainWalletRoute stores authoritative wallet-to-gateway routing metadata.
type ChainWalletRoute struct {
	storable.Base `bson:",inline" json:",inline"`

	OrganizationRef string `bson:"organizationRef" json:"organizationRef"`
	WalletRef       string `bson:"walletRef" json:"walletRef"`
	Network         string `bson:"network" json:"network"`
	GatewayID       string `bson:"gatewayId,omitempty" json:"gatewayId,omitempty"`
}

func (*ChainWalletRoute) Collection() string {
	return mservice.WalletRoutes
}

func (r *ChainWalletRoute) Normalize() {
	r.OrganizationRef = strings.TrimSpace(r.OrganizationRef)
	r.WalletRef = strings.TrimSpace(r.WalletRef)
	r.Network = strings.ToLower(strings.TrimSpace(r.Network))
	r.GatewayID = strings.TrimSpace(r.GatewayID)
}
