-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrequests.go
105 lines (95 loc) · 2.63 KB
/
requests.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package slidesutil
import (
slides "google.golang.org/api/slides/v1"
)
func CreateSlideRequestLayout(predefinedLayout string) *slides.Request {
return &slides.Request{
CreateSlide: &slides.CreateSlideRequest{
SlideLayoutReference: &slides.LayoutReference{
PredefinedLayout: predefinedLayout,
},
},
}
}
func InsertTextRequest(objectID, text string) *slides.Request {
return &slides.Request{
InsertText: &slides.InsertTextRequest{
ObjectId: objectID,
Text: text,
},
}
}
func UpdateTextStyleRequestBold(objectID string, startIdx, endIdx int64) *slides.Request {
return &slides.Request{
UpdateTextStyle: &slides.UpdateTextStyleRequest{
ObjectId: objectID,
Style: &slides.TextStyle{Bold: true},
TextRange: &slides.Range{
Type: RangeTypeFixedRange, StartIndex: &startIdx, EndIndex: &endIdx},
Fields: "bold",
},
}
}
func UpdateTextStyleRequestBullet(objectID string, startIdx, endIdx int64) *slides.Request {
return &slides.Request{
CreateParagraphBullets: &slides.CreateParagraphBulletsRequest{
ObjectId: objectID,
TextRange: &slides.Range{
Type: RangeTypeFixedRange,
StartIndex: &startIdx,
EndIndex: &endIdx},
},
}
}
func UpdateTextStyleRequestFontSizePT(objectID string, pointSize float64) *slides.Request {
return UpdateTextStyleRequestFontSize(objectID,
slides.Dimension{
Magnitude: pointSize,
Unit: "PT"})
}
func UpdateTextStyleRequestFontSize(objectID string, dimension slides.Dimension) *slides.Request {
return &slides.Request{
UpdateTextStyle: &slides.UpdateTextStyleRequest{
ObjectId: objectID,
Style: &slides.TextStyle{FontSize: &dimension},
Fields: "fontSize",
},
}
}
func UpdateParagraphStyleRequestLineSpacing(objectID string, lineSpacing float64) *slides.Request {
return &slides.Request{
UpdateParagraphStyle: &slides.UpdateParagraphStyleRequest{
ObjectId: objectID,
Style: &slides.ParagraphStyle{
LineSpacing: lineSpacing,
},
Fields: "lineSpacing",
},
}
}
/*
func OptionalColorHex() {
c := &slides.OptionalColor{
OpaqueColor: {
RgbColor: &slides.RgbColor{},
},
}
}
*/
func UpdateTextStyleRequestLinkURL(objectID, url string, textRange *slides.Range, underlineLinks bool) *slides.Request {
optionalColor, err := OptionalColorParseHex("#666666")
if err != nil {
panic(err)
}
return &slides.Request{
UpdateTextStyle: &slides.UpdateTextStyleRequest{
ObjectId: objectID,
TextRange: textRange,
Style: &slides.TextStyle{
ForegroundColor: optionalColor,
Link: &slides.Link{Url: url},
Underline: underlineLinks},
Fields: "link,underline,foregroundColor",
},
}
}