Skip to content

Commit d0d683b

Browse files
SDK regenerated by CI server [ci skip]
1 parent 3addc47 commit d0d683b

File tree

11 files changed

+322
-70
lines changed

11 files changed

+322
-70
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ This repository contains Aspose.Words Cloud SDK for Ruby source code. This SDK a
1717

1818
- Properties Name, Text, StartRange, EndRange marked as required for InsertBookmark operation.
1919
- Implemented DeleteOfficeMathObjects operation to delete all office math objects from document.
20+
- Parameter ProtectionRequest was removed from the UnprotectDocument operation. Now removing protection from a document does not require a password.
21+
- Model ProtectionRequest marked as deprecated, please use ProtectionRequestV2 instead for perform ProtectDocument operation. To change the password or protection type of protected document, the old password is no required.
2022

2123

2224
## Enhancements in Version 23.11

lib/aspose_words_cloud.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
require_relative 'aspose_words_cloud/models/protection_data'
202202
require_relative 'aspose_words_cloud/models/protection_data_response'
203203
require_relative 'aspose_words_cloud/models/protection_request'
204+
require_relative 'aspose_words_cloud/models/protection_request_v2'
204205
require_relative 'aspose_words_cloud/models/ps_save_options_data'
205206
require_relative 'aspose_words_cloud/models/public_key_response'
206207
require_relative 'aspose_words_cloud/models/range_document'

lib/aspose_words_cloud/api/words_api.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10958,7 +10958,7 @@ def optimize_document_online(request)
1095810958
[data, status_code, headers]
1095910959
end
1096010960

10961-
# Adds protection to the document.
10961+
# Changes the document protection. The previous protection will be overwritten if it exist.
1096210962
# @param request ProtectDocumentRequest
1096310963
# @return [ProtectionDataResponse]
1096410964
def protect_document(request)
@@ -10975,7 +10975,7 @@ def protect_document(request)
1097510975
data
1097610976
end
1097710977

10978-
# Adds protection to the document.
10978+
# Changes the document protection. The previous protection will be overwritten if it exist.
1097910979
# @param request ProtectDocumentRequest
1098010980
# @return [Array<(ProtectionDataResponse, Fixnum, Hash)>]
1098110981
# ProtectionDataResponse, response status code and response headers
@@ -11000,7 +11000,7 @@ def protect_document(request)
1100011000
[data, status_code, headers]
1100111001
end
1100211002

11003-
# Adds protection to the document.
11003+
# Changes the document protection. The previous protection will be overwritten if it exist.
1100411004
# @param request ProtectDocumentOnlineRequest
1100511005
# @return [ProtectDocumentOnlineResponse]
1100611006
def protect_document_online(request)
@@ -11017,7 +11017,7 @@ def protect_document_online(request)
1101711017
data
1101811018
end
1101911019

11020-
# Adds protection to the document.
11020+
# Changes the document protection. The previous protection will be overwritten if it exist.
1102111021
# @param request ProtectDocumentOnlineRequest
1102211022
# @return [Array<(ProtectDocumentOnlineResponse, Fixnum, Hash)>]
1102311023
# ProtectDocumentOnlineResponse, response status code and response headers

lib/aspose_words_cloud/api_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def initialize(config = Configuration.default)
5656
@default_headers = {
5757
'Content-Type' => "application/json",
5858
'x-aspose-client' => "ruby sdk",
59-
'x-aspose-version' => AsposeWordsCloud::VERSION.to_s
59+
'x-aspose-client-version' => AsposeWordsCloud::VERSION.to_s
6060
}
6161
end
6262

lib/aspose_words_cloud/models/protection_data.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,29 @@ module AsposeWordsCloud
3131
class ProtectionData
3232
# Gets or sets type of the protection.
3333
attr_accessor :protection_type
34+
35+
class EnumAttributeValidator
36+
attr_reader :datatype
37+
attr_reader :allowable_values
38+
39+
def initialize(datatype, allowable_values)
40+
@allowable_values = allowable_values.map do |value|
41+
case datatype.to_s
42+
when /Integer/i
43+
value.to_i
44+
when /Float/i
45+
value.to_f
46+
else
47+
value
48+
end
49+
end
50+
end
51+
52+
def valid?(value)
53+
!value || allowable_values.include?(value)
54+
end
55+
end
56+
3457
# Attribute mapping from ruby-style variable name to JSON key.
3558
def self.attribute_map
3659
{
@@ -61,9 +84,27 @@ def initialize(attributes = {})
6184
# Check to see if the all the properties in the model are valid
6285
# @return true if the model is valid
6386
def valid?
87+
protection_type_validator = EnumAttributeValidator.new('String', ["AllowOnlyRevisions", "AllowOnlyComments", "AllowOnlyFormFields", "ReadOnly", "NoProtection"])
88+
return false unless protection_type_validator.valid?(@protection_type)
89+
6490
return true
6591
end
6692

93+
# Custom attribute writer method checking allowed values (enum).
94+
# @param [Object] protection_type Object to be assigned
95+
def protection_type=(protection_type)
96+
validator = EnumAttributeValidator.new('String', ["AllowOnlyRevisions", "AllowOnlyComments", "AllowOnlyFormFields", "ReadOnly", "NoProtection"])
97+
if protection_type.to_i == 0
98+
unless validator.valid?(protection_type)
99+
raise ArgumentError, "invalid value for 'protection_type', must be one of #{validator.allowable_values}."
100+
end
101+
@protection_type = protection_type
102+
else
103+
@protection_type = validator.allowable_values[protection_type.to_i]
104+
end
105+
end
106+
107+
67108
# Checks equality by comparing each attribute.
68109
# @param [Object] Object to be compared
69110
def ==(other)
@@ -198,6 +239,7 @@ def collectFilesContent(resultFilesContent)
198239
end
199240

200241
def validate()
242+
raise ArgumentError, 'Property protection_type in ProtectionData is required.' if self.protection_type.nil?
201243
end
202244

203245
end
Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
# ------------------------------------------------------------------------------------
2+
# <copyright company="Aspose" file="protection_request_v2.rb">
3+
# Copyright (c) 2023 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+
require 'date'
27+
28+
module AsposeWordsCloud
29+
30+
# Request on changing of protection.
31+
class ProtectionRequestV2
32+
# Gets or sets the new password for the document protection.
33+
# This property is required, but empty value is allowed.
34+
attr_accessor :protection_password
35+
36+
# Gets or sets the new type of the document protection.
37+
attr_accessor :protection_type
38+
39+
class EnumAttributeValidator
40+
attr_reader :datatype
41+
attr_reader :allowable_values
42+
43+
def initialize(datatype, allowable_values)
44+
@allowable_values = allowable_values.map do |value|
45+
case datatype.to_s
46+
when /Integer/i
47+
value.to_i
48+
when /Float/i
49+
value.to_f
50+
else
51+
value
52+
end
53+
end
54+
end
55+
56+
def valid?(value)
57+
!value || allowable_values.include?(value)
58+
end
59+
end
60+
61+
# Attribute mapping from ruby-style variable name to JSON key.
62+
def self.attribute_map
63+
{
64+
:'protection_password' => :'ProtectionPassword',
65+
:'protection_type' => :'ProtectionType'
66+
}
67+
end
68+
69+
# Attribute type mapping.
70+
def self.swagger_types
71+
{
72+
:'protection_password' => :'String',
73+
:'protection_type' => :'String'
74+
}
75+
end
76+
77+
# Initializes the object
78+
# @param [Hash] attributes Model attributes in the form of hash
79+
def initialize(attributes = {})
80+
return unless attributes.is_a?(Hash)
81+
82+
# convert string to symbol for hash key
83+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
84+
85+
if attributes.key?(:'ProtectionPassword')
86+
self.protection_password = attributes[:'ProtectionPassword']
87+
end
88+
89+
if attributes.key?(:'ProtectionType')
90+
self.protection_type = attributes[:'ProtectionType']
91+
end
92+
end
93+
94+
# Check to see if the all the properties in the model are valid
95+
# @return true if the model is valid
96+
def valid?
97+
protection_type_validator = EnumAttributeValidator.new('String', ["AllowOnlyRevisions", "AllowOnlyComments", "AllowOnlyFormFields", "ReadOnly", "NoProtection"])
98+
return false unless protection_type_validator.valid?(@protection_type)
99+
100+
return true
101+
end
102+
103+
# Custom attribute writer method checking allowed values (enum).
104+
# @param [Object] protection_type Object to be assigned
105+
def protection_type=(protection_type)
106+
validator = EnumAttributeValidator.new('String', ["AllowOnlyRevisions", "AllowOnlyComments", "AllowOnlyFormFields", "ReadOnly", "NoProtection"])
107+
if protection_type.to_i == 0
108+
unless validator.valid?(protection_type)
109+
raise ArgumentError, "invalid value for 'protection_type', must be one of #{validator.allowable_values}."
110+
end
111+
@protection_type = protection_type
112+
else
113+
@protection_type = validator.allowable_values[protection_type.to_i]
114+
end
115+
end
116+
117+
118+
# Checks equality by comparing each attribute.
119+
# @param [Object] Object to be compared
120+
def ==(other)
121+
return true if self.equal?(other)
122+
self.class == other.class &&
123+
protection_password == other.protection_password &&
124+
protection_type == other.protection_type
125+
end
126+
127+
# @see the `==` method
128+
# @param [Object] Object to be compared
129+
def eql?(other)
130+
self == other
131+
end
132+
133+
# Calculates hash code according to all attributes.
134+
# @return [Fixnum] Hash code
135+
def hash
136+
[protection_password, protection_type].hash
137+
end
138+
139+
# Builds the object from hash
140+
# @param [Hash] attributes Model attributes in the form of hash
141+
# @return [Object] Returns the model itself
142+
def build_from_hash(attributes)
143+
return nil unless attributes.is_a?(Hash)
144+
self.class.swagger_types.each_pair do |key, type|
145+
if type =~ /\AArray<(.*)>/i
146+
# check to ensure the input is an array given that the the attribute
147+
# is documented as an array but the input is not
148+
if attributes[self.class.attribute_map[key]].is_a?(Array)
149+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
150+
end
151+
elsif !attributes[self.class.attribute_map[key]].nil?
152+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
153+
end
154+
# or else data not found in attributes(hash), not an issue as the data can be optional
155+
end
156+
157+
self
158+
end
159+
160+
# Deserializes the data based on type
161+
# @param string type Data type
162+
# @param string value Value to be deserialized
163+
# @return [Object] Deserialized data
164+
def _deserialize(type, value)
165+
case type.to_sym
166+
when :DateTime
167+
Time.at(/\d/.match(value)[0].to_f).to_datetime
168+
when :Date
169+
Time.at(/\d/.match(value)[0].to_f).to_date
170+
when :String
171+
value.to_s
172+
when :Integer
173+
value.to_i
174+
when :Float
175+
value.to_f
176+
when :BOOLEAN
177+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
178+
true
179+
else
180+
false
181+
end
182+
when :Object
183+
# generic object (usually a Hash), return directly
184+
value
185+
when /\AArray<(?<inner_type>.+)>\z/
186+
inner_type = Regexp.last_match[:inner_type]
187+
value.map { |v| _deserialize(inner_type, v) }
188+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189+
k_type = Regexp.last_match[:k_type]
190+
v_type = Regexp.last_match[:v_type]
191+
{}.tap do |hash|
192+
value.each do |k, v|
193+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194+
end
195+
end
196+
else
197+
# model
198+
if value[:'$type']
199+
type = value[:'$type'][0..-4]
200+
end
201+
202+
temp_model = AsposeWordsCloud.const_get(type).new
203+
temp_model.build_from_hash(value)
204+
end
205+
end
206+
207+
# Returns the string representation of the object
208+
# @return [String] String presentation of the object
209+
def to_s
210+
to_hash.to_s
211+
end
212+
213+
# to_body is an alias to to_hash (backward compatibility)
214+
# @return [Hash] Returns the object in the form of hash
215+
def to_body
216+
to_hash
217+
end
218+
219+
# Returns the object in the form of hash
220+
# @return [Hash] Returns the object in the form of hash
221+
def to_hash
222+
hash = {}
223+
self.class.attribute_map.each_pair do |attr, param|
224+
value = self.send(attr)
225+
next if value.nil?
226+
hash[param] = _to_hash(value)
227+
end
228+
hash
229+
end
230+
231+
# Outputs non-array value in the form of hash
232+
# For object, use to_hash. Otherwise, just return the value
233+
# @param [Object] value Any valid value
234+
# @return [Hash] Returns the value in the form of hash
235+
def _to_hash(value)
236+
if value.is_a?(Array)
237+
value.compact.map { |v| _to_hash(v) }
238+
elsif value.is_a?(Hash)
239+
{}.tap do |hash|
240+
value.each { |k, v| hash[k] = _to_hash(v) }
241+
end
242+
elsif value.respond_to? :to_hash
243+
value.to_hash
244+
else
245+
value
246+
end
247+
end
248+
249+
def collectFilesContent(resultFilesContent)
250+
end
251+
252+
def validate()
253+
raise ArgumentError, 'Property protection_password in ProtectionRequestV2 is required.' if self.protection_password.nil?
254+
raise ArgumentError, 'Property protection_type in ProtectionRequestV2 is required.' if self.protection_type.nil?
255+
end
256+
257+
end
258+
end

0 commit comments

Comments
 (0)