aspose_words_cloud 23.11.0 → 23.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aspose_words_cloud/api/words_api.rb +180 -4
  3. data/lib/aspose_words_cloud/api_client.rb +1 -1
  4. data/lib/aspose_words_cloud/models/bookmark_insert.rb +4 -0
  5. data/lib/aspose_words_cloud/models/compare_data.rb +20 -2
  6. data/lib/aspose_words_cloud/models/protection_data.rb +42 -0
  7. data/lib/aspose_words_cloud/models/protection_request_v2.rb +258 -0
  8. data/lib/aspose_words_cloud/models/requests/compare_document_online_request.rb +3 -14
  9. data/lib/aspose_words_cloud/models/requests/compare_document_request.rb +2 -0
  10. data/lib/aspose_words_cloud/models/requests/delete_office_math_objects_online_request.rb +193 -0
  11. data/lib/aspose_words_cloud/models/requests/delete_office_math_objects_request.rb +192 -0
  12. data/lib/aspose_words_cloud/models/requests/insert_watermark_online_request.rb +218 -0
  13. data/lib/aspose_words_cloud/models/requests/insert_watermark_request.rb +220 -0
  14. data/lib/aspose_words_cloud/models/requests/protect_document_online_request.rb +2 -2
  15. data/lib/aspose_words_cloud/models/requests/protect_document_request.rb +2 -2
  16. data/lib/aspose_words_cloud/models/requests/unprotect_document_online_request.rb +3 -26
  17. data/lib/aspose_words_cloud/models/requests/unprotect_document_request.rb +3 -29
  18. data/lib/aspose_words_cloud/models/responses/insert_watermark_online_response.rb +46 -0
  19. data/lib/aspose_words_cloud/models/structured_document_tag.rb +4 -1
  20. data/lib/aspose_words_cloud/models/structured_document_tag_insert.rb +4 -1
  21. data/lib/aspose_words_cloud/models/structured_document_tag_update.rb +4 -1
  22. data/lib/aspose_words_cloud/models/watermark_data_image.rb +236 -0
  23. data/lib/aspose_words_cloud/models/watermark_data_text.rb +301 -0
  24. data/lib/aspose_words_cloud/version.rb +1 -1
  25. data/lib/aspose_words_cloud.rb +7 -0
  26. metadata +10 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9d29fdfe33ec895dc41caf177242a2871bb7672563aaad8ab9b7184f3fdac89
4
- data.tar.gz: 504bbe0f1ac93ee59ce77d2f028b1cc0a4c698996c5fa3df4fac3f0d57022f26
3
+ metadata.gz: c37260b9556bca1ffb1b4cf0daa6964df472259e0ac856d71ddd6b48ad142857
4
+ data.tar.gz: 2c5563acc9e03b5c244061ea93428afb96619cf06bbb529610bf2e4c1e5277cf
5
5
  SHA512:
6
- metadata.gz: cda37bfc6c42b8df58ee641b19680f72be20cfcf843c3317072567f807ba4387deb2e1f4d46ea861c8af3056997f90b201dbadc0e9415d5bd2e75a468be35b68
7
- data.tar.gz: 3a2f90b498110884e6b7e02971ca6e0ccbd187fb4c6e6939a9ec13a62a890e81fb00d185ff7f9f4365b3a058edece77cb528e394d72eda7a904fedb89055eb4e
6
+ metadata.gz: e1aa550fa7e3fe604271498af63c9390ff31ed7235d11f8f2cde6f5bfa7c791a584c5c5f8910462ca0bd822ac389e4e752d8c82bafca5252655223875285edfc
7
+ data.tar.gz: 3df59927da377b712031c815b9c43c65148fcd47f3cf4f96badfde7885def1e11d09522abb7e78db00365dc190a89903bfcc482fda9283570485aac8164413fc
@@ -2843,6 +2843,90 @@ module AsposeWordsCloud
2843
2843
  [data, status_code, headers]
2844
2844
  end
2845
2845
 
2846
+ # Removes all office math objects from the document.
2847
+ # @param request DeleteOfficeMathObjectsRequest
2848
+ # @return [nil]
2849
+ def delete_office_math_objects(request)
2850
+ begin
2851
+ data, _status_code, _headers = delete_office_math_objects_with_http_info(request)
2852
+ rescue ApiError => e
2853
+ if e.code == 401
2854
+ request_token
2855
+ data, _status_code, _headers = delete_office_math_objects_with_http_info(request)
2856
+ else
2857
+ raise
2858
+ end
2859
+ end
2860
+ nil
2861
+ end
2862
+
2863
+ # Removes all office math objects from the document.
2864
+ # @param request DeleteOfficeMathObjectsRequest
2865
+ # @return [Array<(nil, Fixnum, Hash)>]
2866
+ # nil, response status code and response headers
2867
+ private def delete_office_math_objects_with_http_info(request)
2868
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? DeleteOfficeMathObjectsRequest
2869
+
2870
+ @api_client.config.logger.debug 'Calling API: WordsApi.delete_office_math_objects ...' if @api_client.config.debugging
2871
+ request_data = request.create_http_request(@api_client)
2872
+
2873
+ data, status_code, headers = @api_client.call_api(
2874
+ request_data[:'method'],
2875
+ request_data[:'path'],
2876
+ header_params: request_data[:'header_params'],
2877
+ query_params: request_data[:'query_params'],
2878
+ body: request_data[:'body'])
2879
+ if @api_client.config.debugging
2880
+ @api_client.config.logger.debug "API called:
2881
+ WordsApi#delete_office_math_objects\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
2882
+ end
2883
+
2884
+ [data, status_code, headers]
2885
+ end
2886
+
2887
+ # Removes all office math objects from the document.
2888
+ # @param request DeleteOfficeMathObjectsOnlineRequest
2889
+ # @return [FILES_COLLECTION]
2890
+ def delete_office_math_objects_online(request)
2891
+ begin
2892
+ data, _status_code, _headers = delete_office_math_objects_online_with_http_info(request)
2893
+ rescue ApiError => e
2894
+ if e.code == 401
2895
+ request_token
2896
+ data, _status_code, _headers = delete_office_math_objects_online_with_http_info(request)
2897
+ else
2898
+ raise
2899
+ end
2900
+ end
2901
+ data
2902
+ end
2903
+
2904
+ # Removes all office math objects from the document.
2905
+ # @param request DeleteOfficeMathObjectsOnlineRequest
2906
+ # @return [Array<(FILES_COLLECTION, Fixnum, Hash)>]
2907
+ # FILES_COLLECTION, response status code and response headers
2908
+ private def delete_office_math_objects_online_with_http_info(request)
2909
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? DeleteOfficeMathObjectsOnlineRequest
2910
+
2911
+ @api_client.config.logger.debug 'Calling API: WordsApi.delete_office_math_objects_online ...' if @api_client.config.debugging
2912
+ request_data = request.create_http_request(@api_client)
2913
+
2914
+ data, status_code, headers = @api_client.call_api(
2915
+ request_data[:'method'],
2916
+ request_data[:'path'],
2917
+ header_params: request_data[:'header_params'],
2918
+ query_params: request_data[:'query_params'],
2919
+ body: request_data[:'body'],
2920
+ return_type: 'FILES_COLLECTION')
2921
+ if @api_client.config.debugging
2922
+ @api_client.config.logger.debug "API called:
2923
+ WordsApi#delete_office_math_objects_online\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
2924
+ end
2925
+
2926
+ # FILES_COLLECTION #
2927
+ [data, status_code, headers]
2928
+ end
2929
+
2846
2930
  # Removes a paragraph from the document node.
2847
2931
  # @param request DeleteParagraphRequest
2848
2932
  # @return [nil]
@@ -10449,10 +10533,53 @@ module AsposeWordsCloud
10449
10533
  [mp_data, status_code, headers]
10450
10534
  end
10451
10535
 
10536
+ # Insert a watermark to the document.
10537
+ # @param request InsertWatermarkRequest
10538
+ # @return [DocumentResponse]
10539
+ def insert_watermark(request)
10540
+ begin
10541
+ data, _status_code, _headers = insert_watermark_with_http_info(request)
10542
+ rescue ApiError => e
10543
+ if e.code == 401
10544
+ request_token
10545
+ data, _status_code, _headers = insert_watermark_with_http_info(request)
10546
+ else
10547
+ raise
10548
+ end
10549
+ end
10550
+ data
10551
+ end
10552
+
10553
+ # Insert a watermark to the document.
10554
+ # @param request InsertWatermarkRequest
10555
+ # @return [Array<(DocumentResponse, Fixnum, Hash)>]
10556
+ # DocumentResponse, response status code and response headers
10557
+ private def insert_watermark_with_http_info(request)
10558
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? InsertWatermarkRequest
10559
+
10560
+ @api_client.config.logger.debug 'Calling API: WordsApi.insert_watermark ...' if @api_client.config.debugging
10561
+ request_data = request.create_http_request(@api_client)
10562
+
10563
+ data, status_code, headers = @api_client.call_api(
10564
+ request_data[:'method'],
10565
+ request_data[:'path'],
10566
+ header_params: request_data[:'header_params'],
10567
+ query_params: request_data[:'query_params'],
10568
+ body: request_data[:'body'],
10569
+ return_type: 'DocumentResponse')
10570
+ if @api_client.config.debugging
10571
+ @api_client.config.logger.debug "API called:
10572
+ WordsApi#insert_watermark\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
10573
+ end
10574
+
10575
+ [data, status_code, headers]
10576
+ end
10577
+
10452
10578
  # Inserts a new watermark image to the document.
10453
10579
  # @param request InsertWatermarkImageRequest
10454
10580
  # @return [DocumentResponse]
10455
10581
  def insert_watermark_image(request)
10582
+ warn "This operation is deprecated and is used for backward compatibility only. Please use InsertWatermark instead."
10456
10583
  begin
10457
10584
  data, _status_code, _headers = insert_watermark_image_with_http_info(request)
10458
10585
  rescue ApiError => e
@@ -10495,6 +10622,7 @@ module AsposeWordsCloud
10495
10622
  # @param request InsertWatermarkImageOnlineRequest
10496
10623
  # @return [InsertWatermarkImageOnlineResponse]
10497
10624
  def insert_watermark_image_online(request)
10625
+ warn "This operation is deprecated and is used for backward compatibility only. Please use InsertWatermark instead."
10498
10626
  begin
10499
10627
  data, _status_code, _headers = insert_watermark_image_online_with_http_info(request)
10500
10628
  rescue ApiError => e
@@ -10537,10 +10665,57 @@ module AsposeWordsCloud
10537
10665
  [mp_data, status_code, headers]
10538
10666
  end
10539
10667
 
10668
+ # Insert a watermark to the document.
10669
+ # @param request InsertWatermarkOnlineRequest
10670
+ # @return [InsertWatermarkOnlineResponse]
10671
+ def insert_watermark_online(request)
10672
+ begin
10673
+ data, _status_code, _headers = insert_watermark_online_with_http_info(request)
10674
+ rescue ApiError => e
10675
+ if e.code == 401
10676
+ request_token
10677
+ data, _status_code, _headers = insert_watermark_online_with_http_info(request)
10678
+ else
10679
+ raise
10680
+ end
10681
+ end
10682
+ data
10683
+ end
10684
+
10685
+ # Insert a watermark to the document.
10686
+ # @param request InsertWatermarkOnlineRequest
10687
+ # @return [Array<(InsertWatermarkOnlineResponse, Fixnum, Hash)>]
10688
+ # InsertWatermarkOnlineResponse, response status code and response headers
10689
+ private def insert_watermark_online_with_http_info(request)
10690
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? InsertWatermarkOnlineRequest
10691
+
10692
+ @api_client.config.logger.debug 'Calling API: WordsApi.insert_watermark_online ...' if @api_client.config.debugging
10693
+ request_data = request.create_http_request(@api_client)
10694
+
10695
+ data, status_code, headers = @api_client.call_api(
10696
+ request_data[:'method'],
10697
+ request_data[:'path'],
10698
+ header_params: request_data[:'header_params'],
10699
+ query_params: request_data[:'query_params'],
10700
+ body: request_data[:'body'],
10701
+ multipart_response: true,
10702
+ return_type: 'InsertWatermarkOnlineResponse')
10703
+ if @api_client.config.debugging
10704
+ @api_client.config.logger.debug "API called:
10705
+ WordsApi#insert_watermark_online\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
10706
+ end
10707
+
10708
+ mp_data = InsertWatermarkOnlineResponse.new()
10709
+ mp_data.model = @api_client.deserialize(data['Model'][:data], data['Model'][:headers], 'DocumentResponse')
10710
+ mp_data.document = @api_client.parse_files_collection(data['Document'][:data], data['Document'][:headers])
10711
+ [mp_data, status_code, headers]
10712
+ end
10713
+
10540
10714
  # Inserts a new watermark text to the document.
10541
10715
  # @param request InsertWatermarkTextRequest
10542
10716
  # @return [DocumentResponse]
10543
10717
  def insert_watermark_text(request)
10718
+ warn "This operation is deprecated and is used for backward compatibility only. Please use InsertWatermark instead."
10544
10719
  begin
10545
10720
  data, _status_code, _headers = insert_watermark_text_with_http_info(request)
10546
10721
  rescue ApiError => e
@@ -10583,6 +10758,7 @@ module AsposeWordsCloud
10583
10758
  # @param request InsertWatermarkTextOnlineRequest
10584
10759
  # @return [InsertWatermarkTextOnlineResponse]
10585
10760
  def insert_watermark_text_online(request)
10761
+ warn "This operation is deprecated and is used for backward compatibility only. Please use InsertWatermark instead."
10586
10762
  begin
10587
10763
  data, _status_code, _headers = insert_watermark_text_online_with_http_info(request)
10588
10764
  rescue ApiError => e
@@ -10874,7 +11050,7 @@ module AsposeWordsCloud
10874
11050
  [data, status_code, headers]
10875
11051
  end
10876
11052
 
10877
- # Adds protection to the document.
11053
+ # Changes the document protection. The previous protection will be overwritten if it exist.
10878
11054
  # @param request ProtectDocumentRequest
10879
11055
  # @return [ProtectionDataResponse]
10880
11056
  def protect_document(request)
@@ -10891,7 +11067,7 @@ module AsposeWordsCloud
10891
11067
  data
10892
11068
  end
10893
11069
 
10894
- # Adds protection to the document.
11070
+ # Changes the document protection. The previous protection will be overwritten if it exist.
10895
11071
  # @param request ProtectDocumentRequest
10896
11072
  # @return [Array<(ProtectionDataResponse, Fixnum, Hash)>]
10897
11073
  # ProtectionDataResponse, response status code and response headers
@@ -10916,7 +11092,7 @@ module AsposeWordsCloud
10916
11092
  [data, status_code, headers]
10917
11093
  end
10918
11094
 
10919
- # Adds protection to the document.
11095
+ # Changes the document protection. The previous protection will be overwritten if it exist.
10920
11096
  # @param request ProtectDocumentOnlineRequest
10921
11097
  # @return [ProtectDocumentOnlineResponse]
10922
11098
  def protect_document_online(request)
@@ -10933,7 +11109,7 @@ module AsposeWordsCloud
10933
11109
  data
10934
11110
  end
10935
11111
 
10936
- # Adds protection to the document.
11112
+ # Changes the document protection. The previous protection will be overwritten if it exist.
10937
11113
  # @param request ProtectDocumentOnlineRequest
10938
11114
  # @return [Array<(ProtectDocumentOnlineResponse, Fixnum, Hash)>]
10939
11115
  # ProtectDocumentOnlineResponse, response status code and response headers
@@ -56,7 +56,7 @@ module AsposeWordsCloud
56
56
  @default_headers = {
57
57
  'Content-Type' => "application/json",
58
58
  'x-aspose-client' => "ruby sdk",
59
- 'x-aspose-version' => AsposeWordsCloud::VERSION.to_s
59
+ 'x-aspose-client-version' => AsposeWordsCloud::VERSION.to_s
60
60
  }
61
61
  end
62
62
 
@@ -228,6 +228,10 @@ module AsposeWordsCloud
228
228
  end
229
229
 
230
230
  def validate()
231
+ raise ArgumentError, 'Property name in BookmarkInsert is required.' if self.name.nil?
232
+ raise ArgumentError, 'Property text in BookmarkInsert is required.' if self.text.nil?
233
+ raise ArgumentError, 'Property start_range in BookmarkInsert is required.' if self.start_range.nil?
234
+ raise ArgumentError, 'Property end_range in BookmarkInsert is required.' if self.end_range.nil?
231
235
  unless self.start_range.nil?
232
236
  self.start_range.validate
233
237
  end
@@ -41,6 +41,9 @@ module AsposeWordsCloud
41
41
  # Gets or sets the date and time to use for revisions.
42
42
  attr_accessor :date_time
43
43
 
44
+ # Gets or sets the file reference.
45
+ attr_accessor :file_reference
46
+
44
47
  # Gets or sets the result document format.
45
48
  attr_accessor :result_document_format
46
49
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -50,6 +53,7 @@ module AsposeWordsCloud
50
53
  :'compare_options' => :'CompareOptions',
51
54
  :'comparing_with_document' => :'ComparingWithDocument',
52
55
  :'date_time' => :'DateTime',
56
+ :'file_reference' => :'FileReference',
53
57
  :'result_document_format' => :'ResultDocumentFormat'
54
58
  }
55
59
  end
@@ -61,6 +65,7 @@ module AsposeWordsCloud
61
65
  :'compare_options' => :'CompareOptions',
62
66
  :'comparing_with_document' => :'String',
63
67
  :'date_time' => :'DateTime',
68
+ :'file_reference' => :'FileReference',
64
69
  :'result_document_format' => :'String'
65
70
  }
66
71
  end
@@ -89,6 +94,10 @@ module AsposeWordsCloud
89
94
  self.date_time = attributes[:'DateTime']
90
95
  end
91
96
 
97
+ if attributes.key?(:'FileReference')
98
+ self.file_reference = attributes[:'FileReference']
99
+ end
100
+
92
101
  if attributes.key?(:'ResultDocumentFormat')
93
102
  self.result_document_format = attributes[:'ResultDocumentFormat']
94
103
  end
@@ -109,6 +118,7 @@ module AsposeWordsCloud
109
118
  compare_options == other.compare_options &&
110
119
  comparing_with_document == other.comparing_with_document &&
111
120
  date_time == other.date_time &&
121
+ file_reference == other.file_reference &&
112
122
  result_document_format == other.result_document_format
113
123
  end
114
124
 
@@ -121,7 +131,7 @@ module AsposeWordsCloud
121
131
  # Calculates hash code according to all attributes.
122
132
  # @return [Fixnum] Hash code
123
133
  def hash
124
- [author, compare_options, comparing_with_document, date_time, result_document_format].hash
134
+ [author, compare_options, comparing_with_document, date_time, file_reference, result_document_format].hash
125
135
  end
126
136
 
127
137
  # Builds the object from hash
@@ -235,14 +245,22 @@ module AsposeWordsCloud
235
245
  end
236
246
 
237
247
  def collectFilesContent(resultFilesContent)
248
+ if self.file_reference
249
+ self.file_reference.collectFilesContent(resultFilesContent)
250
+ end
251
+
252
+
238
253
  end
239
254
 
240
255
  def validate()
241
256
  raise ArgumentError, 'Property author in CompareData is required.' if self.author.nil?
242
- raise ArgumentError, 'Property comparing_with_document in CompareData is required.' if self.comparing_with_document.nil?
257
+ raise ArgumentError, 'Property file_reference in CompareData is required.' if self.file_reference.nil?
243
258
  unless self.compare_options.nil?
244
259
  self.compare_options.validate
245
260
  end
261
+ unless self.file_reference.nil?
262
+ self.file_reference.validate
263
+ end
246
264
 
247
265
  end
248
266
 
@@ -31,6 +31,29 @@ module AsposeWordsCloud
31
31
  class ProtectionData
32
32
  # Gets or sets type of the protection.
33
33
  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
+
34
57
  # Attribute mapping from ruby-style variable name to JSON key.
35
58
  def self.attribute_map
36
59
  {
@@ -61,9 +84,27 @@ module AsposeWordsCloud
61
84
  # Check to see if the all the properties in the model are valid
62
85
  # @return true if the model is valid
63
86
  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
+
64
90
  return true
65
91
  end
66
92
 
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
+
67
108
  # Checks equality by comparing each attribute.
68
109
  # @param [Object] Object to be compared
69
110
  def ==(other)
@@ -198,6 +239,7 @@ module AsposeWordsCloud
198
239
  end
199
240
 
200
241
  def validate()
242
+ raise ArgumentError, 'Property protection_type in ProtectionData is required.' if self.protection_type.nil?
201
243
  end
202
244
 
203
245
  end
@@ -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