-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
reports.go
43 lines (34 loc) · 933 Bytes
/
reports.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
package bamboohr
import (
"fmt"
)
// BBHRGetCompanayReportInput is used as input for the GetCompanyReport function
type BBHRGetCompanyReportInput struct {
ReportID string
Format string
FD string
}
// GetCompanyReport gets a company report
func (b *Client) GetCompanyReport(args BBHRGetCompanyReportInput) ([]byte, error) {
if args.ReportID == "" {
return []byte{}, fmt.Errorf("missing arg: ReportID")
}
endpointURL := fmt.Sprintf("%s/reports/%s", b.APIEndpoint, args.ReportID)
if args.Format == "" {
return []byte{}, fmt.Errorf("missing arg: Format")
}
switch args.Format {
case "csv":
case "pdf":
case "xls":
case "xml":
case "json":
default:
return []byte{}, fmt.Errorf("arg 'format' must be one of: csv, pdf, xls, xml, json")
}
endpointURL += fmt.Sprintf("&format=%s", args.Format)
if args.FD != "" {
endpointURL += fmt.Sprintf("&fd=%s", args.FD)
}
return b.getRequest(endpointURL)
}