forked from keybase/client
/
notify_ctl.go
63 lines (55 loc) · 1.85 KB
/
notify_ctl.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
// Auto-generated by avdl-compiler v1.3.1 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/notify_ctl.avdl
package keybase1
import (
rpc "github.com/keybase/go-framed-msgpack-rpc"
context "golang.org/x/net/context"
)
type NotificationChannels struct {
Session bool `codec:"session" json:"session"`
Users bool `codec:"users" json:"users"`
Kbfs bool `codec:"kbfs" json:"kbfs"`
Tracking bool `codec:"tracking" json:"tracking"`
Favorites bool `codec:"favorites" json:"favorites"`
Paperkeys bool `codec:"paperkeys" json:"paperkeys"`
Keyfamily bool `codec:"keyfamily" json:"keyfamily"`
Service bool `codec:"service" json:"service"`
App bool `codec:"app" json:"app"`
}
type SetNotificationsArg struct {
Channels NotificationChannels `codec:"channels" json:"channels"`
}
type NotifyCtlInterface interface {
SetNotifications(context.Context, NotificationChannels) error
}
func NotifyCtlProtocol(i NotifyCtlInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.notifyCtl",
Methods: map[string]rpc.ServeHandlerDescription{
"setNotifications": {
MakeArg: func() interface{} {
ret := make([]SetNotificationsArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]SetNotificationsArg)
if !ok {
err = rpc.NewTypeError((*[]SetNotificationsArg)(nil), args)
return
}
err = i.SetNotifications(ctx, (*typedArgs)[0].Channels)
return
},
MethodType: rpc.MethodCall,
},
},
}
}
type NotifyCtlClient struct {
Cli rpc.GenericClient
}
func (c NotifyCtlClient) SetNotifications(ctx context.Context, channels NotificationChannels) (err error) {
__arg := SetNotificationsArg{Channels: channels}
err = c.Cli.Call(ctx, "keybase.1.notifyCtl.setNotifications", []interface{}{__arg}, nil)
return
}