forked from thecodingmachine/gotenberg-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
office.go
50 lines (40 loc) · 1.06 KB
/
office.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
package gotenberg
import (
"strconv"
)
const (
landscapeOffice string = "landscape"
pageRangesOffice string = "pageRanges"
)
// OfficeRequest facilitates Office documents
// conversion with the Gotenberg API.
type OfficeRequest struct {
docs []Document
*request
}
// NewOfficeRequest create OfficeRequest.
func NewOfficeRequest(docs ...Document) *OfficeRequest {
return &OfficeRequest{docs, newRequest()}
}
// Landscape sets landscape form field.
func (req *OfficeRequest) Landscape(isLandscape bool) {
req.values[landscapeOffice] = strconv.FormatBool(isLandscape)
}
// PageRanges sets pageRanges form field.
func (req *OfficeRequest) PageRanges(ranges string) {
req.values[pageRangesOffice] = ranges
}
func (req *OfficeRequest) postURL() string {
return "/convert/office"
}
func (req *OfficeRequest) formFiles() map[string]Document {
files := make(map[string]Document)
for _, doc := range req.docs {
files[doc.Filename()] = doc
}
return files
}
// Compile-time checks to ensure type implements desired interfaces.
var (
_ = Request(new(OfficeRequest))
)