Skip to content

Commit 3ea282f

Browse files
Merge branch 'master' into release
2 parents 5c616f4 + 6649adb commit 3ea282f

File tree

8 files changed

+699
-2
lines changed

8 files changed

+699
-2
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ This repository contains Aspose.Words Cloud SDK for Ruby source code. This SDK a
1313
* Watermarks and protection
1414
* Full read & write access to Document Object Model, including sections, paragraphs, text, images, tables, headers/footers and many others
1515

16+
## Enhancements in Version 24.6
17+
18+
- Added the 'TranslateNodeId' method to transalate a node id to a node path.
19+
20+
1621
## Enhancements in Version 24.5
1722

1823
- Added the support of multistorage operations. Saving a file as a result of an operation can be performed in a specific storage, when, used file path in the next format '@storage:path/to/file.doc'.
@@ -332,7 +337,7 @@ To use Aspose Words for Cloud Ruby SDK you need to register an account with [Asp
332337
To install this package do the following:
333338
update your Gemfile
334339
```ruby
335-
gem 'aspose_words_cloud', '~> 24.5'
340+
gem 'aspose_words_cloud', '~> 24.6'
336341
```
337342
or install directly
338343
```bash

lib/aspose_words_cloud.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@
278278
require_relative 'aspose_words_cloud/models/text_save_options_data'
279279
require_relative 'aspose_words_cloud/models/tiff_save_options_data'
280280
require_relative 'aspose_words_cloud/models/time_zone_info_data'
281+
require_relative 'aspose_words_cloud/models/translate_node_id_response'
281282
require_relative 'aspose_words_cloud/models/user_information'
282283
require_relative 'aspose_words_cloud/models/watermark_data_image'
283284
require_relative 'aspose_words_cloud/models/watermark_data_text'
@@ -585,6 +586,8 @@
585586
require_relative 'aspose_words_cloud/models/requests/search_online_request'
586587
require_relative 'aspose_words_cloud/models/requests/split_document_request'
587588
require_relative 'aspose_words_cloud/models/requests/split_document_online_request'
589+
require_relative 'aspose_words_cloud/models/requests/translate_node_id_request'
590+
require_relative 'aspose_words_cloud/models/requests/translate_node_id_online_request'
588591
require_relative 'aspose_words_cloud/models/requests/unprotect_document_request'
589592
require_relative 'aspose_words_cloud/models/requests/unprotect_document_online_request'
590593
require_relative 'aspose_words_cloud/models/requests/update_bookmark_request'

lib/aspose_words_cloud/api/words_api.rb

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12474,6 +12474,90 @@ def split_document_online(request)
1247412474
[mp_data, status_code, headers]
1247512475
end
1247612476

12477+
# Translate a node id to a node path.
12478+
# @param request TranslateNodeIdRequest
12479+
# @return [TranslateNodeIdResponse]
12480+
def translate_node_id(request)
12481+
begin
12482+
data, _status_code, _headers = translate_node_id_with_http_info(request)
12483+
rescue ApiError => e
12484+
if e.code == 401
12485+
request_token
12486+
data, _status_code, _headers = translate_node_id_with_http_info(request)
12487+
else
12488+
raise
12489+
end
12490+
end
12491+
data
12492+
end
12493+
12494+
# Translate a node id to a node path.
12495+
# @param request TranslateNodeIdRequest
12496+
# @return [Array<(TranslateNodeIdResponse, Fixnum, Hash)>]
12497+
# TranslateNodeIdResponse, response status code and response headers
12498+
private def translate_node_id_with_http_info(request)
12499+
raise ArgumentError, 'Incorrect request type' unless request.is_a? TranslateNodeIdRequest
12500+
12501+
@api_client.config.logger.debug 'Calling API: WordsApi.translate_node_id ...' if @api_client.config.debugging
12502+
request_data = request.create_http_request(@api_client)
12503+
12504+
data, status_code, headers = @api_client.call_api(
12505+
request_data[:'method'],
12506+
request_data[:'path'],
12507+
header_params: request_data[:'header_params'],
12508+
query_params: request_data[:'query_params'],
12509+
body: request_data[:'body'],
12510+
return_type: 'TranslateNodeIdResponse')
12511+
if @api_client.config.debugging
12512+
@api_client.config.logger.debug "API called:
12513+
WordsApi#translate_node_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
12514+
end
12515+
12516+
[data, status_code, headers]
12517+
end
12518+
12519+
# Translate a node id to a node path.
12520+
# @param request TranslateNodeIdOnlineRequest
12521+
# @return [TranslateNodeIdResponse]
12522+
def translate_node_id_online(request)
12523+
begin
12524+
data, _status_code, _headers = translate_node_id_online_with_http_info(request)
12525+
rescue ApiError => e
12526+
if e.code == 401
12527+
request_token
12528+
data, _status_code, _headers = translate_node_id_online_with_http_info(request)
12529+
else
12530+
raise
12531+
end
12532+
end
12533+
data
12534+
end
12535+
12536+
# Translate a node id to a node path.
12537+
# @param request TranslateNodeIdOnlineRequest
12538+
# @return [Array<(TranslateNodeIdResponse, Fixnum, Hash)>]
12539+
# TranslateNodeIdResponse, response status code and response headers
12540+
private def translate_node_id_online_with_http_info(request)
12541+
raise ArgumentError, 'Incorrect request type' unless request.is_a? TranslateNodeIdOnlineRequest
12542+
12543+
@api_client.config.logger.debug 'Calling API: WordsApi.translate_node_id_online ...' if @api_client.config.debugging
12544+
request_data = request.create_http_request(@api_client)
12545+
12546+
data, status_code, headers = @api_client.call_api(
12547+
request_data[:'method'],
12548+
request_data[:'path'],
12549+
header_params: request_data[:'header_params'],
12550+
query_params: request_data[:'query_params'],
12551+
body: request_data[:'body'],
12552+
return_type: 'TranslateNodeIdResponse')
12553+
if @api_client.config.debugging
12554+
@api_client.config.logger.debug "API called:
12555+
WordsApi#translate_node_id_online\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
12556+
end
12557+
12558+
[data, status_code, headers]
12559+
end
12560+
1247712561
# Removes protection from the document.
1247812562
# @param request UnprotectDocumentRequest
1247912563
# @return [ProtectionDataResponse]
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# ------------------------------------------------------------------------------------
2+
# <copyright company="Aspose" file="translate_node_id_online_request.rb">
3+
# Copyright (c) 2024 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 translate_node_id_online operation.
30+
#
31+
class TranslateNodeIdOnlineRequest
32+
# The document.
33+
attr_accessor :document
34+
35+
# The node identifier. Identifier examples: id0.0.0.
36+
attr_accessor :node_id
37+
38+
# Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.
39+
attr_accessor :load_encoding
40+
41+
# 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.
42+
attr_accessor :password
43+
44+
# Password of protected Word document. Use the parameter to pass an encrypted password for direct calls of API. See SDK code for encyption details.
45+
attr_accessor :encrypted_password
46+
47+
#
48+
# Initializes a new instance.
49+
# @param document The document.
50+
# @param node_id The node identifier. Identifier examples: id0.0.0.
51+
# @param load_encoding Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.
52+
# @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.
53+
# @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.
54+
55+
def initialize(document:, node_id:, load_encoding: nil, password: nil, encrypted_password: nil)
56+
self.document = document
57+
self.node_id = node_id
58+
self.load_encoding = load_encoding
59+
self.password = password
60+
self.encrypted_password = encrypted_password
61+
end
62+
63+
# Creating batch part from request
64+
def to_batch_part(api_client, requestId, parentRequestId = nil)
65+
# verify the required parameter 'document' is set
66+
raise ArgumentError, 'Missing the required parameter document when calling WordsApi.translate_node_id_online' if api_client.config.client_side_validation && self.document.nil?
67+
# verify the required parameter 'node_id' is set
68+
raise ArgumentError, 'Missing the required parameter node_id when calling WordsApi.translate_node_id_online' if api_client.config.client_side_validation && self.node_id.nil?
69+
70+
# resource path
71+
local_var_path = '/words/online/get/translate/{nodeId}'[7..-1]
72+
local_var_path = local_var_path.sub('{' + downcase_first_letter('NodeId') + '}', self.node_id.nil? ? '' : self.node_id.to_s)
73+
local_var_path = local_var_path.sub('//', '/')
74+
75+
# query parameters
76+
query_params = {}
77+
query_params[downcase_first_letter('LoadEncoding')] = self.load_encoding unless self.load_encoding.nil?
78+
query_params[downcase_first_letter('Password')] = self.password unless self.password.nil?
79+
query_params[downcase_first_letter('EncryptedPassword')] = self.encrypted_password unless self.encrypted_password.nil?
80+
81+
if query_params
82+
query_params.each { |key, value| local_var_path = api_client.add_param_to_query(local_var_path, key, value) }
83+
end
84+
85+
header_params = {}
86+
# header parameters
87+
# HTTP header 'Content-Type'
88+
header_params['Content-Type'] = api_client.select_header_content_type(['multipart/form-data'])
89+
header_params['RequestId'] = requestId
90+
91+
if parentRequestId != nil
92+
header_params['DependsOn'] = parentRequestId
93+
end
94+
95+
# form parameters
96+
form_params = []
97+
files_content = []
98+
if self.document.nil?
99+
raise "Parameter Document is required."
100+
end
101+
unless self.document.nil?
102+
form_params.push({:'Name' => 'document', :'Data' => self.document, :'MimeType' =>'application/octet-stream'})
103+
end
104+
105+
106+
# http body (model)
107+
body = api_client.build_request_body_batch(header_params, form_params, files_content)
108+
part = ""
109+
part.concat("PUT".force_encoding('UTF-8'))
110+
part.concat(" ".force_encoding('UTF-8'))
111+
part.concat(local_var_path.force_encoding('UTF-8'))
112+
part.concat(" \r\n".force_encoding('UTF-8'))
113+
114+
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')) }
115+
part.concat("\r\n".force_encoding('UTF-8'))
116+
if body
117+
if body.is_a?(Hash)
118+
body.each do |key, value|
119+
part.concat(value, "\r\n")
120+
end
121+
else
122+
part.concat(body)
123+
end
124+
end
125+
part
126+
end
127+
128+
def create_http_request(api_client)
129+
# verify the required parameter 'document' is set
130+
raise ArgumentError, 'Missing the required parameter document when calling WordsApi.translate_node_id_online' if api_client.config.client_side_validation && self.document.nil?
131+
# verify the required parameter 'node_id' is set
132+
raise ArgumentError, 'Missing the required parameter node_id when calling WordsApi.translate_node_id_online' if api_client.config.client_side_validation && self.node_id.nil?
133+
134+
# resource path
135+
local_var_path = '/words/online/get/translate/{nodeId}'[1..-1]
136+
local_var_path = local_var_path.sub('{' + downcase_first_letter('NodeId') + '}', self.node_id.nil? ? '' : self.node_id.to_s)
137+
local_var_path = local_var_path.sub('//', '/')
138+
139+
# query parameters
140+
query_params = {}
141+
query_params[downcase_first_letter('LoadEncoding')] = self.load_encoding unless self.load_encoding.nil?
142+
query_params[downcase_first_letter('Password')] = self.password unless self.password.nil?
143+
query_params[downcase_first_letter('EncryptedPassword')] = self.encrypted_password unless self.encrypted_password.nil?
144+
145+
# header parameters
146+
header_params = {}
147+
# HTTP header 'Content-Type'
148+
header_params['Content-Type'] = api_client.select_header_content_type(['multipart/form-data'])
149+
150+
# form parameters
151+
form_params = []
152+
files_content = []
153+
if self.document.nil?
154+
raise "Parameter Document is required."
155+
end
156+
unless self.document.nil?
157+
form_params.push({:'Name' => 'document', :'Data' => self.document, :'MimeType' =>'application/octet-stream'})
158+
end
159+
160+
body = api_client.build_request_body(header_params, form_params, files_content)
161+
{
162+
'method': :PUT,
163+
'path': local_var_path,
164+
'header_params': header_params,
165+
'query_params': query_params,
166+
'body': body,
167+
'auth_names': ['JWT']
168+
}
169+
end
170+
171+
#
172+
# Helper method to convert first letter to downcase
173+
#
174+
def downcase_first_letter(str)
175+
str[0].downcase + str[1..-1]
176+
end
177+
178+
# Get response type
179+
def get_response_type
180+
'TranslateNodeIdResponse'
181+
end
182+
end
183+
end

0 commit comments

Comments
 (0)