-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes.go
69 lines (55 loc) · 1.29 KB
/
types.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
package golibre
import (
"encoding/json"
"time"
)
type LoginResponse struct {
Status uint `json:"status"`
Data LoginData `json:"data"`
}
type LoginData struct {
User map[string]any `json:"user"`
Messages map[string]any `json:"messages"`
Notifications map[string]any `json:"notifications"`
AuthTicket AuthTicket `json:"authTicket"`
Invitations []any `json:"invitations"`
TrustedDeviceToken string `json:"trustedDeviceToken"`
}
type AuthTicket struct {
Token string `json:"token"`
Expires uint64 `json:"expires"`
Duration uint64 `json:"duration"`
}
type (
PatientID string
UserID string
UnitOfMeasurement uint
)
const (
MMOL UnitOfMeasurement = iota
DL
)
/*
Timestamp requires custom unmarshalling due to being returned
by the Libreview API in the following format: 'M/D/YYYY H:M:S PM'
Example data returned: "9/20/2024 3:42:05 PM".
*/
type Timestamp time.Time
func (t *Timestamp) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
time, err := time.Parse("1/2/2006 3:4:5 PM", s)
if err != nil {
return err
}
*t = Timestamp(time)
return nil
}
type StatusCode uint
const (
StatusOK StatusCode = iota
_
StatusUnauthenticated
)