1
+ /*
2
+ * --------------------------------------------------------------------------------
3
+ * <copyright company="Aspose" file="copy_styles_from_template_request.go">
4
+ * Copyright (c) 2022 Aspose.Words for Cloud
5
+ * </copyright>
6
+ * <summary>
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ * </summary>
25
+ * --------------------------------------------------------------------------------
26
+ */
27
+
28
+ package models
29
+
30
+ import (
31
+ "fmt"
32
+ "net/url"
33
+ "strings"
34
+ "io"
35
+ "encoding/json"
36
+ )
37
+
38
+ // CopyStylesFromTemplateRequest contains request data for WordsApiService.CopyStylesFromTemplate method.
39
+ type CopyStylesFromTemplateRequest struct {
40
+ // The filename of the target document.
41
+ Name * string
42
+ // The filename of the origin document.
43
+ TemplateName * string
44
+ /* optional (nil or map[string]interface{}) with one or more of key / value pairs:
45
+ key: "folder" value: (*string) Original document folder.
46
+ key: "storage" value: (*string) Original document storage.
47
+ key: "loadEncoding" value: (*string) Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.
48
+ key: "password" value: (*string) Password of protected Word document. Use the parameter to pass a password via SDK. SDK encrypts it automatically. We don't recommend to use the parameter to pass a plain password for direct call of API.
49
+ key: "encryptedPassword" value: (*string) Password of protected Word document. Use the parameter to pass an encrypted password for direct calls of API. See SDK code for encyption details.
50
+ key: "destFileName" value: (*string) Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.
51
+ key: "revisionAuthor" value: (*string) Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.
52
+ key: "revisionDateTime" value: (*string) The date and time to use for revisions. */
53
+ Optionals map [string ]interface {}
54
+ }
55
+
56
+
57
+ func (data * CopyStylesFromTemplateRequest ) CreateRequestData () (RequestData , error ) {
58
+
59
+ var result RequestData
60
+
61
+ result .Method = strings .ToUpper ("put" )
62
+
63
+ // create path and map variables
64
+ result .Path = "/words/{name}/styles/copy_from"
65
+ result .Path = strings .Replace (result .Path , "{" + "name" + "}" , fmt .Sprintf ("%v" , * data .Name ), - 1 )
66
+
67
+ result .Path = strings .Replace (result .Path , "/<nil>" , "" , - 1 )
68
+ result .Path = strings .Replace (result .Path , "//" , "/" , - 1 )
69
+
70
+ result .HeaderParams = make (map [string ]string )
71
+ result .QueryParams = url.Values {}
72
+ result .FormParams = make ([]FormParamContainer , 0 )
73
+
74
+
75
+ if err := typeCheckParameter (data .Optionals ["folder" ], "string" , "data.Optionals[folder]" ); err != nil {
76
+ return result , err
77
+ }
78
+ if err := typeCheckParameter (data .Optionals ["storage" ], "string" , "data.Optionals[storage]" ); err != nil {
79
+ return result , err
80
+ }
81
+ if err := typeCheckParameter (data .Optionals ["loadEncoding" ], "string" , "data.Optionals[loadEncoding]" ); err != nil {
82
+ return result , err
83
+ }
84
+ if err := typeCheckParameter (data .Optionals ["password" ], "string" , "data.Optionals[password]" ); err != nil {
85
+ return result , err
86
+ }
87
+ if err := typeCheckParameter (data .Optionals ["encryptedPassword" ], "string" , "data.Optionals[encryptedPassword]" ); err != nil {
88
+ return result , err
89
+ }
90
+ if err := typeCheckParameter (data .Optionals ["destFileName" ], "string" , "data.Optionals[destFileName]" ); err != nil {
91
+ return result , err
92
+ }
93
+ if err := typeCheckParameter (data .Optionals ["revisionAuthor" ], "string" , "data.Optionals[revisionAuthor]" ); err != nil {
94
+ return result , err
95
+ }
96
+ if err := typeCheckParameter (data .Optionals ["revisionDateTime" ], "string" , "data.Optionals[revisionDateTime]" ); err != nil {
97
+ return result , err
98
+ }
99
+
100
+
101
+ result .QueryParams .Add ("TemplateName" , parameterToString (* data .TemplateName , "" ))
102
+
103
+
104
+ if localVarTempParam , localVarOk := data .Optionals ["folder" ].(string ); localVarOk {
105
+ result .QueryParams .Add ("Folder" , parameterToString (localVarTempParam , "" ))
106
+ }
107
+
108
+
109
+ if localVarTempParam , localVarOk := data .Optionals ["storage" ].(string ); localVarOk {
110
+ result .QueryParams .Add ("Storage" , parameterToString (localVarTempParam , "" ))
111
+ }
112
+
113
+
114
+ if localVarTempParam , localVarOk := data .Optionals ["loadEncoding" ].(string ); localVarOk {
115
+ result .QueryParams .Add ("LoadEncoding" , parameterToString (localVarTempParam , "" ))
116
+ }
117
+
118
+
119
+ if localVarTempParam , localVarOk := data .Optionals ["password" ].(string ); localVarOk {
120
+ result .QueryParams .Add ("Password" , parameterToString (localVarTempParam , "" ))
121
+ }
122
+
123
+
124
+ if localVarTempParam , localVarOk := data .Optionals ["encryptedPassword" ].(string ); localVarOk {
125
+ result .QueryParams .Add ("EncryptedPassword" , parameterToString (localVarTempParam , "" ))
126
+ }
127
+
128
+
129
+ if localVarTempParam , localVarOk := data .Optionals ["destFileName" ].(string ); localVarOk {
130
+ result .QueryParams .Add ("DestFileName" , parameterToString (localVarTempParam , "" ))
131
+ }
132
+
133
+
134
+ if localVarTempParam , localVarOk := data .Optionals ["revisionAuthor" ].(string ); localVarOk {
135
+ result .QueryParams .Add ("RevisionAuthor" , parameterToString (localVarTempParam , "" ))
136
+ }
137
+
138
+
139
+ if localVarTempParam , localVarOk := data .Optionals ["revisionDateTime" ].(string ); localVarOk {
140
+ result .QueryParams .Add ("RevisionDateTime" , parameterToString (localVarTempParam , "" ))
141
+ }
142
+
143
+
144
+ // to determine the Content-Type header
145
+ localVarHttpContentTypes := []string { "application/xml" , "application/json" , }
146
+
147
+ // set Content-Type header
148
+ localVarHttpContentType := selectHeaderContentType (localVarHttpContentTypes )
149
+ if localVarHttpContentType != "" {
150
+ result .HeaderParams ["Content-Type" ] = localVarHttpContentType
151
+ }
152
+
153
+ // to determine the Accept header
154
+ localVarHttpHeaderAccepts := []string {
155
+ "application/xml" ,
156
+ "application/json" ,
157
+ }
158
+
159
+ // set Accept header
160
+ localVarHttpHeaderAccept := selectHeaderAccept (localVarHttpHeaderAccepts )
161
+ if localVarHttpHeaderAccept != "" {
162
+ result .HeaderParams ["Accept" ] = localVarHttpHeaderAccept
163
+ }
164
+
165
+
166
+
167
+
168
+ return result , nil
169
+ }
170
+
171
+ func (data * CopyStylesFromTemplateRequest ) CreateResponse (reader io.Reader , boundary string ) (response interface {}, err error ) {
172
+ var successPayload WordsResponse
173
+ if err = json .NewDecoder (reader ).Decode (& successPayload ); err != nil {
174
+ return nil , err
175
+ }
176
+
177
+ return successPayload , err
178
+ }
0 commit comments