package model

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

type OrganizationBase struct {
	PermissionBound `bson:",inline" json:",inline"`
	Describable     `bson:",inline" json:",inline"`
	TenantRef       primitive.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          []primitive.ObjectID `bson:"members" json:"members"`
}

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

const (
	OrganizationRefField = "organizationRef"
)

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

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

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