-
Notifications
You must be signed in to change notification settings - Fork 17
/
manager_report.go
39 lines (29 loc) · 1.04 KB
/
manager_report.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
package proton
import (
"context"
"github.com/go-resty/resty/v2"
)
func (m *Manager) ReportBug(ctx context.Context, req ReportBugReq, atts ...ReportBugAttachment) (ReportBugRes, error) {
r := m.r(ctx).SetMultipartFormData(req.toFormData())
for _, att := range atts {
r = r.SetMultipartField(att.Name, att.Filename, string(att.MIMEType), resty.NewByteMultipartStream(att.Body))
}
var res ReportBugRes
if resp, err := r.SetResult(&res).Post("/core/v4/reports/bug"); err != nil {
if resp != nil {
return ReportBugRes{}, &resty.ResponseError{Response: resp, Err: err}
}
return ReportBugRes{}, err
}
return res, nil
}
func (m *Manager) ReportBugAttachement(ctx context.Context, req ReportBugAttachmentReq, atts ...ReportBugAttachment) error {
r := m.r(ctx).SetMultipartFormData(req.toFormData())
for _, att := range atts {
r = r.SetMultipartField(att.Name, att.Filename, string(att.MIMEType), resty.NewByteMultipartStream(att.Body))
}
if _, err := r.Post("/core/v4/reports/bug/attachments"); err != nil {
return err
}
return nil
}