Skip to content

Commit e1ea8c5

Browse files
SDK regenerated by CI server [ci skip]
1 parent 8ffa97d commit e1ea8c5

File tree

8 files changed

+299
-4
lines changed

8 files changed

+299
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ To use Aspose Words for Cloud Ruby SDK you need to register an account with [Asp
194194
To install this package do the following:
195195
update your Gemfile
196196
```ruby
197-
gem 'aspose_words_cloud', '~> 22.3'
197+
gem 'aspose_words_cloud', '~> 22.4'
198198
```
199199
or install directly
200200
```bash
11.8 KB
Binary file not shown.

lib/aspose_words_cloud.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@
304304
require_relative 'aspose_words_cloud/models/requests/copy_folder_request'
305305
require_relative 'aspose_words_cloud/models/requests/copy_style_request'
306306
require_relative 'aspose_words_cloud/models/requests/copy_style_online_request'
307+
require_relative 'aspose_words_cloud/models/requests/copy_styles_from_template_request'
307308
require_relative 'aspose_words_cloud/models/requests/create_document_request'
308309
require_relative 'aspose_words_cloud/models/requests/create_folder_request'
309310
require_relative 'aspose_words_cloud/models/requests/create_or_update_document_property_request'

lib/aspose_words_cloud/api/words_api.rb

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,82 @@ def copy_style_online(request)
13951395
[mp_data, status_code, headers]
13961396
end
13971397

1398+
# Copies styles from the origin document to the target document.
1399+
# @param request CopyStylesFromTemplateRequest
1400+
# @return [WordsResponse]
1401+
def copy_styles_from_template(request)
1402+
begin
1403+
data, _status_code, _headers = copy_styles_from_template_with_http_info(request)
1404+
rescue ApiError => e
1405+
if e.code == 401
1406+
request_token
1407+
data, _status_code, _headers = copy_styles_from_template_with_http_info(request)
1408+
else
1409+
raise
1410+
end
1411+
end
1412+
data
1413+
end
1414+
1415+
# Copies styles from the origin document to the target document.
1416+
# @param request CopyStylesFromTemplateRequest
1417+
# @return [Array<(WordsResponse, Fixnum, Hash)>]
1418+
# WordsResponse, response status code and response headers
1419+
private def copy_styles_from_template_with_http_info(request)
1420+
raise ArgumentError, 'Incorrect request type' unless request.is_a? CopyStylesFromTemplateRequest
1421+
1422+
@api_client.config.logger.debug 'Calling API: WordsApi.copy_styles_from_template ...' if @api_client.config.debugging
1423+
# verify the required parameter 'name' is set
1424+
raise ArgumentError, 'Missing the required parameter name when calling WordsApi.copy_styles_from_template' if @api_client.config.client_side_validation && request.name.nil?
1425+
# verify the required parameter 'template_name' is set
1426+
raise ArgumentError, 'Missing the required parameter template_name when calling WordsApi.copy_styles_from_template' if @api_client.config.client_side_validation && request.template_name.nil?
1427+
1428+
# resource path
1429+
local_var_path = '/words/{name}/styles/copy_from'[1..-1]
1430+
local_var_path = local_var_path.sub('{' + downcase_first_letter('Name') + '}', request.name.nil? ? '' : request.name.to_s)
1431+
local_var_path = local_var_path.sub('//', '/')
1432+
1433+
# query parameters
1434+
query_params = {}
1435+
query_params[downcase_first_letter('TemplateName')] = request.template_name
1436+
query_params[downcase_first_letter('Folder')] = request.folder unless request.folder.nil?
1437+
query_params[downcase_first_letter('Storage')] = request.storage unless request.storage.nil?
1438+
query_params[downcase_first_letter('LoadEncoding')] = request.load_encoding unless request.load_encoding.nil?
1439+
query_params[downcase_first_letter('Password')] = request.password unless request.password.nil?
1440+
query_params[downcase_first_letter('EncryptedPassword')] = request.encrypted_password unless request.encrypted_password.nil?
1441+
query_params[downcase_first_letter('DestFileName')] = request.dest_file_name unless request.dest_file_name.nil?
1442+
query_params[downcase_first_letter('RevisionAuthor')] = request.revision_author unless request.revision_author.nil?
1443+
query_params[downcase_first_letter('RevisionDateTime')] = request.revision_date_time unless request.revision_date_time.nil?
1444+
1445+
# header parameters
1446+
header_params = {}
1447+
# HTTP header 'Accept' (if needed)
1448+
header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])
1449+
# HTTP header 'Content-Type'
1450+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/xml', 'application/json'])
1451+
1452+
# form parameters
1453+
form_params = {}
1454+
1455+
# http body (model)
1456+
post_body = nil
1457+
auth_names = ['JWT']
1458+
1459+
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
1460+
header_params: header_params,
1461+
query_params: query_params,
1462+
form_params: form_params,
1463+
body: post_body,
1464+
auth_names: auth_names,
1465+
return_type: 'WordsResponse')
1466+
if @api_client.config.debugging
1467+
@api_client.config.logger.debug "API called:
1468+
WordsApi#copy_styles_from_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1469+
end
1470+
1471+
[data, status_code, headers]
1472+
end
1473+
13981474
# Supported extensions: ".doc", ".docx", ".docm", ".dot", ".dotm", ".dotx", ".flatopc", ".fopc", ".flatopc_macro", ".fopc_macro", ".flatopc_template", ".fopc_template", ".flatopc_template_macro", ".fopc_template_macro", ".wordml", ".wml", ".rtf".
13991475
# @param request CreateDocumentRequest
14001476
# @return [DocumentResponse]

lib/aspose_words_cloud/models/pdf_save_options_data.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def valid?
526526
return false unless color_mode_validator.valid?(@color_mode)
527527
numeral_format_validator = EnumAttributeValidator.new('String', ["European", "ArabicIndic", "EasternArabicIndic", "Context", "System"])
528528
return false unless numeral_format_validator.valid?(@numeral_format)
529-
compliance_validator = EnumAttributeValidator.new('String', ["Pdf17", "Pdf20", "PdfA1a", "PdfA1b", "PdfA2a", "PdfA2u", "PdfUa1"])
529+
compliance_validator = EnumAttributeValidator.new('String', ["Pdf17", "Pdf20", "PdfA1a", "PdfA1b", "PdfA2a", "PdfA2u", "PdfA4", "PdfUa1"])
530530
return false unless compliance_validator.valid?(@compliance)
531531
custom_properties_export_validator = EnumAttributeValidator.new('String', ["None", "Standard", "Metadata"])
532532
return false unless custom_properties_export_validator.valid?(@custom_properties_export)
@@ -633,7 +633,7 @@ def numeral_format=(numeral_format)
633633
# Custom attribute writer method checking allowed values (enum).
634634
# @param [Object] compliance Object to be assigned
635635
def compliance=(compliance)
636-
validator = EnumAttributeValidator.new('String', ["Pdf17", "Pdf20", "PdfA1a", "PdfA1b", "PdfA2a", "PdfA2u", "PdfUa1"])
636+
validator = EnumAttributeValidator.new('String', ["Pdf17", "Pdf20", "PdfA1a", "PdfA1b", "PdfA2a", "PdfA2u", "PdfA4", "PdfUa1"])
637637
if compliance.to_i == 0
638638
unless validator.valid?(compliance)
639639
raise ArgumentError, "invalid value for 'compliance', must be one of #{validator.allowable_values}."
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# ------------------------------------------------------------------------------------
2+
# <copyright company="Aspose" file="copy_styles_from_template_request.rb">
3+
# Copyright (c) 2022 Aspose.Words for Cloud
4+
# </copyright>
5+
# <summary>
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
# </summary>
24+
# ------------------------------------------------------------------------------------
25+
26+
module AsposeWordsCloud
27+
28+
#
29+
# Request model for copy_styles_from_template operation.
30+
#
31+
class CopyStylesFromTemplateRequest
32+
# The filename of the target document.
33+
attr_accessor :name
34+
35+
# The filename of the origin document.
36+
attr_accessor :template_name
37+
38+
# Original document folder.
39+
attr_accessor :folder
40+
41+
# Original document storage.
42+
attr_accessor :storage
43+
44+
# Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.
45+
attr_accessor :load_encoding
46+
47+
# 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.
48+
attr_accessor :password
49+
50+
# Password of protected Word document. Use the parameter to pass an encrypted password for direct calls of API. See SDK code for encyption details.
51+
attr_accessor :encrypted_password
52+
53+
# 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.
54+
attr_accessor :dest_file_name
55+
56+
# 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.
57+
attr_accessor :revision_author
58+
59+
# The date and time to use for revisions.
60+
attr_accessor :revision_date_time
61+
62+
#
63+
# Initializes a new instance.
64+
# @param name The filename of the target document.
65+
# @param template_name The filename of the origin document.
66+
# @param folder Original document folder.
67+
# @param storage Original document storage.
68+
# @param load_encoding Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.
69+
# @param password 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.
70+
# @param encrypted_password Password of protected Word document. Use the parameter to pass an encrypted password for direct calls of API. See SDK code for encyption details.
71+
# @param dest_file_name 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.
72+
# @param revision_author 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.
73+
# @param revision_date_time The date and time to use for revisions.
74+
75+
def initialize(name:, template_name:, folder: nil, storage: nil, load_encoding: nil, password: nil, encrypted_password: nil, dest_file_name: nil, revision_author: nil, revision_date_time: nil)
76+
self.name = name
77+
self.template_name = template_name
78+
self.folder = folder
79+
self.storage = storage
80+
self.load_encoding = load_encoding
81+
self.password = password
82+
self.encrypted_password = encrypted_password
83+
self.dest_file_name = dest_file_name
84+
self.revision_author = revision_author
85+
self.revision_date_time = revision_date_time
86+
end
87+
88+
# Creating batch part from request
89+
def to_batch_part(api_client, guid)
90+
# verify the required parameter 'name' is set
91+
raise ArgumentError, 'Missing the required parameter name when calling WordsApi.copy_styles_from_template' if api_client.config.client_side_validation && self.name.nil?
92+
# verify the required parameter 'template_name' is set
93+
raise ArgumentError, 'Missing the required parameter template_name when calling WordsApi.copy_styles_from_template' if api_client.config.client_side_validation && self.template_name.nil?
94+
95+
# resource path
96+
local_var_path = '/words/{name}/styles/copy_from'[7..-1]
97+
local_var_path = local_var_path.sub('{' + downcase_first_letter('Name') + '}', self.name.nil? ? '' : self.name.to_s)
98+
local_var_path = local_var_path.sub('//', '/')
99+
100+
# query parameters
101+
query_params = {}
102+
query_params[downcase_first_letter('TemplateName')] = self.template_name
103+
query_params[downcase_first_letter('Folder')] = self.folder unless self.folder.nil?
104+
query_params[downcase_first_letter('Storage')] = self.storage unless self.storage.nil?
105+
query_params[downcase_first_letter('LoadEncoding')] = self.load_encoding unless self.load_encoding.nil?
106+
query_params[downcase_first_letter('Password')] = self.password unless self.password.nil?
107+
query_params[downcase_first_letter('EncryptedPassword')] = self.encrypted_password unless self.encrypted_password.nil?
108+
query_params[downcase_first_letter('DestFileName')] = self.dest_file_name unless self.dest_file_name.nil?
109+
query_params[downcase_first_letter('RevisionAuthor')] = self.revision_author unless self.revision_author.nil?
110+
query_params[downcase_first_letter('RevisionDateTime')] = self.revision_date_time unless self.revision_date_time.nil?
111+
112+
if query_params
113+
query_params.each { |key, value| local_var_path = api_client.add_param_to_query(local_var_path, key, value) }
114+
end
115+
116+
header_params = {}
117+
header_params['RequestId'] = guid
118+
119+
# form parameters
120+
form_params = {}
121+
122+
# http body (model)
123+
post_body = nil
124+
body = nil
125+
part = ""
126+
part.concat("PUT".force_encoding('UTF-8'))
127+
part.concat(" ".force_encoding('UTF-8'))
128+
part.concat(local_var_path.force_encoding('UTF-8'))
129+
part.concat(" \r\n".force_encoding('UTF-8'))
130+
131+
header_params.each_pair {|key, value| part.concat(key.dup.force_encoding('UTF-8') , ": ".force_encoding('UTF-8'), value.dup.force_encoding('UTF-8'), "\r\n".force_encoding('UTF-8')) }
132+
part.concat("\r\n".force_encoding('UTF-8'))
133+
if body
134+
if body.is_a?(Hash)
135+
body.each do |key, value|
136+
part.concat(value, "\r\n")
137+
end
138+
else
139+
part.concat(body)
140+
end
141+
end
142+
part
143+
end
144+
145+
def create_http_request(api_client)
146+
# verify the required parameter 'name' is set
147+
raise ArgumentError, 'Missing the required parameter name when calling WordsApi.copy_styles_from_template' if api_client.config.client_side_validation && self.name.nil?
148+
# verify the required parameter 'template_name' is set
149+
raise ArgumentError, 'Missing the required parameter template_name when calling WordsApi.copy_styles_from_template' if api_client.config.client_side_validation && self.template_name.nil?
150+
151+
# resource path
152+
local_var_path = '/words/{name}/styles/copy_from'[1..-1]
153+
local_var_path = local_var_path.sub('{' + downcase_first_letter('Name') + '}', self.name.nil? ? '' : self.name.to_s)
154+
local_var_path = local_var_path.sub('//', '/')
155+
156+
# query parameters
157+
query_params = {}
158+
query_params[downcase_first_letter('TemplateName')] = self.template_name
159+
query_params[downcase_first_letter('Folder')] = self.folder unless self.folder.nil?
160+
query_params[downcase_first_letter('Storage')] = self.storage unless self.storage.nil?
161+
query_params[downcase_first_letter('LoadEncoding')] = self.load_encoding unless self.load_encoding.nil?
162+
query_params[downcase_first_letter('Password')] = self.password unless self.password.nil?
163+
query_params[downcase_first_letter('EncryptedPassword')] = self.encrypted_password unless self.encrypted_password.nil?
164+
query_params[downcase_first_letter('DestFileName')] = self.dest_file_name unless self.dest_file_name.nil?
165+
query_params[downcase_first_letter('RevisionAuthor')] = self.revision_author unless self.revision_author.nil?
166+
query_params[downcase_first_letter('RevisionDateTime')] = self.revision_date_time unless self.revision_date_time.nil?
167+
168+
# header parameters
169+
header_params = {}
170+
# HTTP header 'Content-Type'
171+
header_params['Content-Type'] = api_client.select_header_content_type(['application/xml', 'application/json'])
172+
173+
# form parameters
174+
form_params = {}
175+
176+
# http body (model)
177+
post_body = nil
178+
body = api_client.build_request_body(header_params, form_params, post_body)
179+
{
180+
'method': :PUT,
181+
'path': local_var_path,
182+
'header_params': header_params,
183+
'query_params': query_params,
184+
'body': body,
185+
'auth_names': ['JWT']
186+
}
187+
end
188+
189+
#
190+
# Helper method to convert first letter to downcase
191+
#
192+
def downcase_first_letter(str)
193+
str[0].downcase + str[1..-1]
194+
end
195+
196+
# Get response type
197+
def get_response_type
198+
'WordsResponse'
199+
end
200+
end
201+
end

lib/aspose_words_cloud/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
# ------------------------------------------------------------------------------------
2525

2626
module AsposeWordsCloud
27-
VERSION = "22.3".freeze
27+
VERSION = "22.4".freeze
2828
end

tests/Styles/styles_tests.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,22 @@ def test_apply_style_to_document_element_online
220220
result = @words_api.apply_style_to_document_element_online(request)
221221
assert_equal false, result.nil?
222222
end
223+
224+
#
225+
# Test for copying styles from a template.
226+
#
227+
def test_copy_styles_from_template
228+
remote_file_name = 'TestCopyStylesFromTemplate.docx'
229+
template_folder = 'DocumentElements/Styles'
230+
template_name = 'StyleTemplate.docx'
231+
232+
upload_file File.join(local_test_folder, local_file), remote_data_folder + '/' + remote_file_name
233+
upload_file File.join(local_test_folder, template_folder + '/' + template_name), remote_data_folder + '/' + template_name
234+
235+
request = CopyStylesFromTemplateRequest.new(name: remote_file_name, template_name: template_name, folder: remote_data_folder)
236+
237+
result = @words_api.copy_styles_from_template(request)
238+
assert_equal false, result.nil?
239+
end
223240
end
224241
end

0 commit comments

Comments
 (0)