-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.go
61 lines (48 loc) · 1.96 KB
/
contact.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package malak
import (
"context"
"time"
"github.com/google/uuid"
"github.com/uptrace/bun"
)
const (
ErrContactNotFound = MalakError("contact not found")
ErrContactExists = MalakError("contact with email already exists")
)
// ENUM(mr,mrs,miss,doctor,chief)
type ContactTitle string
type CustomContactMetadata map[string]string
type Contact struct {
ID uuid.UUID `bun:"type:uuid,default:uuid_generate_v4(),pk" json:"id,omitempty"`
Email Email `json:"email,omitempty"`
WorkspaceID uuid.UUID `json:"workspace_id,omitempty"`
Reference Reference `json:"reference,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Company string `json:"company,omitempty"`
City string `json:"city,omitempty"`
Phone string `json:"phone,omitempty"`
Notes string `json:"notes,omitempty"`
Lists []ContactListMapping `json:"lists" bun:"rel:has-many,join:id=contact_id"`
// User who owns the contact.
// Does not mean who added the contact but who chases
// or follows up officially with the contact
OwnerID uuid.UUID `json:"owner_id,omitempty"`
// User who added/created this contact
CreatedBy uuid.UUID `json:"created_by,omitempty"`
Metadata CustomContactMetadata `json:"metadata,omitempty"`
CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"created_at,omitempty"`
UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"updated_at,omitempty"`
DeletedAt *time.Time `bun:",soft_delete,nullzero" json:"-,omitempty"`
bun.BaseModel `json:"-"`
}
type FetchContactOptions struct {
ID uuid.UUID
Email Email
Reference Reference
WorkspaceID uuid.UUID
}
type ContactRepository interface {
Create(context.Context, *Contact) error
Get(context.Context, FetchContactOptions) (*Contact, error)
}