-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathalias.go
More file actions
42 lines (34 loc) · 1.1 KB
/
alias.go
File metadata and controls
42 lines (34 loc) · 1.1 KB
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
package analytics
import "time"
var _ Message = (*Alias)(nil)
// This type represents object sent in a alias call as described in
type Alias struct {
// This field is exported for serialization purposes and shouldn't be set by
// the application, its value is always overwritten by the library.
Type string `json:"type,omitempty"`
MessageId string `json:"messageId,omitempty"`
PreviousId string `json:"previousId"`
UserId string `json:"userId"`
OriginalTimestamp time.Time `json:"originalTimestamp,omitempty"`
SentAt time.Time `json:"sentAt,omitempty"`
Context *Context `json:"context,omitempty"`
Integrations Integrations `json:"integrations,omitempty"`
Channel string `json:"channel,omitempty"`
}
func (msg Alias) Validate() error {
if len(msg.UserId) == 0 {
return FieldError{
Type: "analytics.Alias",
Name: "UserId",
Value: msg.UserId,
}
}
if len(msg.PreviousId) == 0 {
return FieldError{
Type: "analytics.Alias",
Name: "PreviousId",
Value: msg.PreviousId,
}
}
return nil
}