-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
93 lines (76 loc) · 1.85 KB
/
api.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
package main
import ()
type Tristate int
const (
Undefined Tristate = iota
True
False
)
type Endpoint struct {
Api string `json:"api"`
Space string `json:"space"`
Logo string `json:"logo"`
Url string `json:"url"`
Location Location `json:"location"`
State State `json:"state"`
Contact Contact `json:"contact"`
IssueReportChannels []string `json:"issue_report_channels"`
Feeds Feeds
}
type Location struct {
Address string `json:"address"`
Lat float32 `json:"lat"`
Lon float32 `json:"lon"`
}
type State struct {
Open Tristate `json:"open"`
}
type Contact struct {
Irc string `json:"irc"`
List string `json:"ml"`
IssueMail string `json:"issue_mail"`
}
type Feeds struct {
Calendar Feed `json:"calendar"`
}
type Feed struct {
Type string `json:"type"`
Url string `json:"url"`
}
func NewEndpoint() *Endpoint {
ep := &Endpoint{}
ep.Api = "0.13"
ep.Space = "Chaostreff Heidelberg"
ep.Logo = "https://www.noname-ev.de/img/noname.svg"
ep.Url = "https://www.noname-ev.de/"
ep.Location = Location{
Address: "Im Neuenheimer Feld 368, 69120 Heidelberg",
Lat: 49.41759,
Lon: 8.66834,
}
ep.Contact.Irc = "ircs://irc.twice-irc.de/chaos-hd"
ep.Contact.List = "[email protected]"
ep.Contact.IssueMail = "[email protected]"
ep.IssueReportChannels = []string{"issue_mail"}
ep.Feeds = Feeds{Calendar: Feed{
Type: "ical",
Url: "https://www.noname-ev.de/c14h.ics",
}}
return ep
}
func (s Tristate) MarshalJSON() ([]byte, error) {
switch s {
case Undefined:
return []byte("null"), nil
case True:
return []byte("true"), nil
case False:
return []byte("false"), nil
default:
panic("Undefined value for tristate")
}
}
func (s Tristate) String() string {
b, _ := s.MarshalJSON()
return string(b)
}