-
Notifications
You must be signed in to change notification settings - Fork 0
/
contacts_models.go
102 lines (93 loc) · 3.27 KB
/
contacts_models.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package reamaze
import (
"regexp"
"strings"
"time"
)
// Contacts models
type ReamazePhoneNumber string
type ReamazeIdentifier string
const contactsEndpoint string = "/api/v1/contacts"
const (
ReamazeIdentifierEmail ReamazeIdentifier = "email"
ReamazeIdentifierMobile ReamazeIdentifier = "mobile"
ReamazeIdentifierFacebook ReamazeIdentifier = "facebook"
ReamazeIdentifierTwitter ReamazeIdentifier = "twitter"
ReamazeIdentifierInstagram ReamazeIdentifier = "instagram"
)
func (w ReamazePhoneNumber) Validate() bool {
phoneNumber := string(w)
e164RegexString := "^\\+[1-9]?[0-9]{7,14}$"
re := regexp.MustCompile(e164RegexString)
phoneNumber = strings.ReplaceAll(phoneNumber, " ", "")
validPhone := re.Find([]byte(phoneNumber))
return validPhone != nil
}
type GetContactResponse struct {
Name string `json:"name"`
Data interface{} `json:"data"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Email string `json:"email"`
Twitter string `json:"twitter"`
Facebook string `json:"facebook"`
Instagram string `json:"instagram"`
Mobile string `json:"mobile"`
FriendlyName string `json:"friendly_name"`
ID string `json:"id"`
ID0 int `json:"_id"`
Notes []Note `json:"notes"`
}
type GetContactsResponse struct {
PageSize int `json:"page_size"`
PageCount int `json:"page_count"`
TotalCount int `json:"total_count"`
Contacts []struct {
Name string `json:"name"`
Data interface{} `json:"data"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Email string `json:"email"`
Twitter string `json:"twitter"`
Facebook string `json:"facebook"`
Instagram string `json:"instagram"`
Mobile string `json:"mobile"`
FriendlyName string `json:"friendly_name"`
ID int `json:"_id"`
Notes []Note `json:"notes"`
ID0 string `json:"id,omitempty"`
} `json:"contacts"`
}
type CreateContactRequest struct {
Contact struct {
Name string `json:"name"`
Email string `json:"email"`
Mobile ReamazePhoneNumber `json:"mobile"`
FriendlyName string `json:"friendly_name"`
ID string `json:"id"`
ExternalAvatarURL string `json:"external_avatar_url"`
Notes []string `json:"notes"`
Data interface{} `json:"data"`
} `json:"contact"`
}
type UpdateContactRequest struct {
Contact struct {
Name string `json:"name"`
FriendlyName string `json:"friendly_name"`
ExternalAvatarURL string `json:"external_avatar_url"`
Notes []string `json:"notes"`
Data any `json:"data"`
} `json:"contact"`
}
type GetContactIdentitiesResponse struct {
Identities []struct {
Type ReamazeIdentifier `json:"type"`
Identifier string `json:"identifier"`
} `json:"identities"`
}
type CreateContactIdentitiesRequest struct {
Identity struct {
Type ReamazeIdentifier `json:"type"`
Identifier string `json:"identifier"`
} `json:"identity"`
}