/
schema.go
45 lines (40 loc) · 1011 Bytes
/
schema.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
package bark
import (
"fmt"
"strings"
)
// Device represents a registered device with Bark app installed that receives notifications.
type Device struct {
endpointURL string
deviceKey string
}
func (d Device) String() string {
return fmt.Sprintf("(Dev: %s @ %s)", d.deviceKey, d.endpointURL)
}
// Options represents options for notification request.
type Options struct {
Ringtone RingtoneName
OpenURL string
CopyText string
ForceArchive bool
ForceCopy bool
}
func (o Options) String() string {
var parts []string
if isNotBlank(string(o.Ringtone)) {
parts = append(parts, fmt.Sprintf("Ringtone=%s", o.Ringtone))
}
if isNotBlank(o.OpenURL) {
parts = append(parts, fmt.Sprintf("URL=%s", o.OpenURL))
}
if isNotBlank(o.CopyText) {
parts = append(parts, fmt.Sprintf("Copy=%q", o.CopyText))
}
if o.ForceArchive {
parts = append(parts, "Archive")
}
if o.ForceCopy {
parts = append(parts, "AutoCopy")
}
return fmt.Sprintf("(Opt: %s)", strings.Join(parts, ", "))
}