forked from nyaruka/courier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.go
33 lines (26 loc) · 852 Bytes
/
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
package courier
import (
"strings"
uuid "github.com/satori/go.uuid"
)
// ContactUUID is our typing of a contact's UUID
type ContactUUID struct {
uuid.UUID
}
// NilContactUUID is our nil value for contact UUIDs
var NilContactUUID = ContactUUID{uuid.Nil}
// NewContactUUID creates a new ContactUUID for the passed in string
func NewContactUUID(u string) (ContactUUID, error) {
contactUUID, err := uuid.FromString(strings.ToLower(u))
if err != nil {
return NilContactUUID, err
}
return ContactUUID{contactUUID}, nil
}
//-----------------------------------------------------------------------------
// Contact Interface
//-----------------------------------------------------------------------------
// Contact defines the attributes on a contact, for our purposes that is just a contact UUID
type Contact interface {
UUID() ContactUUID
}