- Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathuser_email.go
43 lines (36 loc) · 1.05 KB
/
user_email.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
// Copyright 2015 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gogs
import (
"bytes"
"encoding/json"
)
typeEmailstruct {
Emailstring`json:"email"`
Verifiedbool`json:"verified"`
Primarybool`json:"primary"`
}
func (c*Client) ListEmails() ([]*Email, error) {
emails:=make([]*Email, 0, 3)
returnemails, c.getParsedResponse("GET", "/user/emails", nil, nil, &emails)
}
typeCreateEmailOptionstruct {
Emails []string`json:"emails"`
}
func (c*Client) AddEmail(optCreateEmailOption) ([]*Email, error) {
body, err:=json.Marshal(&opt)
iferr!=nil {
returnnil, err
}
emails:=make([]*Email, 0, 3)
returnemails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), emails)
}
func (c*Client) DeleteEmail(optCreateEmailOption) error {
body, err:=json.Marshal(&opt)
iferr!=nil {
returnerr
}
_, err=c.getResponse("DELETE", "/user/emails", jsonHeader, bytes.NewReader(body))
returnerr
}