-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathclick_source.go
39 lines (37 loc) · 1011 Bytes
/
click_source.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
package models
type ClickSource int
const (
UNKNOWN_CLICKSOURCE ClickSource = iota
QRCODE_CLICKSOURCE
PHISHINGURL_CLICKSOURCE
UNKNOWNFUTUREVALUE_CLICKSOURCE
)
func (i ClickSource) String() string {
return []string{"unknown", "qrCode", "phishingUrl", "unknownFutureValue"}[i]
}
func ParseClickSource(v string) (any, error) {
result := UNKNOWN_CLICKSOURCE
switch v {
case "unknown":
result = UNKNOWN_CLICKSOURCE
case "qrCode":
result = QRCODE_CLICKSOURCE
case "phishingUrl":
result = PHISHINGURL_CLICKSOURCE
case "unknownFutureValue":
result = UNKNOWNFUTUREVALUE_CLICKSOURCE
default:
return nil, nil
}
return &result, nil
}
func SerializeClickSource(values []ClickSource) []string {
result := make([]string, len(values))
for i, v := range values {
result[i] = v.String()
}
return result
}
func (i ClickSource) isMultiValue() bool {
return false
}