summaryrefslogtreecommitdiff
path: root/app/domain/entity.go
blob: 0dc399523de9b247f64ab8657eb88baac4d343e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package domain

import (
	"errors"

	v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
)

type Entity interface {
	Identifiable
	Validate() error
}

type defaultEntity struct {
	ID ID `json:"id" jsonapi:"primary,entities"`
}

func (s *defaultEntity) GetID() ID {
	return s.ID
}

func (s *defaultEntity) SetID(id ID) error {
	s.ID = id
	return nil
}

func (s *defaultEntity) ToGID() string {
	return "gid://sparkle/Entity/" + s.ID.String()
}

func (self *defaultEntity) ToObjectReference() *v1.ObjectReference {
	return &v1.ObjectReference{
		ObjectType: "entity",
		ObjectId:   self.ID.String(),
	}
}

func (s *defaultEntity) Validate() error {
	return errors.New("method Validate not implemented")
}