package model

import (
	"github.com/tech/sendico/pkg/mservice"
	"go.mongodb.org/mongo-driver/v2/bson"
)

type OrganizationBase struct {
	PermissionBound `bson:",inline" json:",inline"`
	Describable     `bson:",inline" json:",inline"`
	TenantRef       bson.ObjectID `bson:"tenantRef" json:"tenantRef"`
	TimeZone        string        `bson:"timeZone" json:"timeZone"`
	LogoURL         *string       `bson:"logoUrl,omitempty" json:"logoUrl,omitempty"`
}

func (*OrganizationBase) Collection() string {
	return mservice.Organizations
}

type Organization struct {
	OrganizationBase `bson:",inline" json:",inline"`
	Members          []bson.ObjectID `bson:"members" json:"members"`
}

type OrganizationBound interface {
	GetOrganizationRef() bson.ObjectID
	SetOrganizationRef(organizationRef bson.ObjectID)
}

const (
	OrganizationRefField = "organizationRef"
)

type OrganizationBoundBase struct {
	OrganizationRef bson.ObjectID `bson:"organizationRef" json:"organizationRef"`
}

func (a *OrganizationBoundBase) GetOrganizationRef() bson.ObjectID {
	return a.OrganizationRef
}

func (a *OrganizationBoundBase) SetOrganizationRef(organizationRef bson.ObjectID) {
	a.OrganizationRef = organizationRef
}
