|
| 1 | +# ------------------------------------------------------------------------------------ |
| 2 | +# <copyright company="Aspose" file="get_all_revisions_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 get_all_revisions_online operation. |
| 30 | + # |
| 31 | + class GetAllRevisionsOnlineRequest |
| 32 | + # The document. |
| 33 | + attr_accessor :document |
| 34 | + |
| 35 | + # Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML. |
| 36 | + attr_accessor :load_encoding |
| 37 | + |
| 38 | + # 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. |
| 39 | + attr_accessor :password |
| 40 | + |
| 41 | + # Password of protected Word document. Use the parameter to pass an encrypted password for direct calls of API. See SDK code for encyption details. |
| 42 | + attr_accessor :encrypted_password |
| 43 | + |
| 44 | + # The value indicates whether OpenType support is on. |
| 45 | + attr_accessor :open_type_support |
| 46 | + |
| 47 | + # |
| 48 | + # Initializes a new instance. |
| 49 | + # @param document The document. |
| 50 | + # @param load_encoding Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML. |
| 51 | + # @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. |
| 52 | + # @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. |
| 53 | + # @param open_type_support The value indicates whether OpenType support is on. |
| 54 | + |
| 55 | + def initialize(document:, load_encoding: nil, password: nil, encrypted_password: nil, open_type_support: nil) |
| 56 | + self.document = document |
| 57 | + self.load_encoding = load_encoding |
| 58 | + self.password = password |
| 59 | + self.encrypted_password = encrypted_password |
| 60 | + self.open_type_support = open_type_support |
| 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.get_all_revisions_online' if api_client.config.client_side_validation && self.document.nil? |
| 67 | + |
| 68 | + # resource path |
| 69 | + local_var_path = '/words/online/get/revisions/getAll'[7..-1] |
| 70 | + local_var_path = local_var_path.sub('//', '/') |
| 71 | + |
| 72 | + # query parameters |
| 73 | + query_params = {} |
| 74 | + query_params[downcase_first_letter('LoadEncoding')] = self.load_encoding unless self.load_encoding.nil? |
| 75 | + query_params[downcase_first_letter('Password')] = self.password unless self.password.nil? |
| 76 | + query_params[downcase_first_letter('EncryptedPassword')] = self.encrypted_password unless self.encrypted_password.nil? |
| 77 | + query_params[downcase_first_letter('OpenTypeSupport')] = self.open_type_support unless self.open_type_support.nil? |
| 78 | + |
| 79 | + if query_params |
| 80 | + query_params.each { |key, value| local_var_path = api_client.add_param_to_query(local_var_path, key, value) } |
| 81 | + end |
| 82 | + |
| 83 | + header_params = {} |
| 84 | + # header parameters |
| 85 | + # HTTP header 'Content-Type' |
| 86 | + header_params['Content-Type'] = api_client.select_header_content_type(['multipart/form-data']) |
| 87 | + header_params['RequestId'] = requestId |
| 88 | + |
| 89 | + if parentRequestId != nil |
| 90 | + header_params['DependsOn'] = parentRequestId |
| 91 | + end |
| 92 | + |
| 93 | + # form parameters |
| 94 | + form_params = [] |
| 95 | + files_content = [] |
| 96 | + if self.document.nil? |
| 97 | + raise "Parameter Document is required." |
| 98 | + end |
| 99 | + unless self.document.nil? |
| 100 | + form_params.push({:'Name' => 'document', :'Data' => self.document, :'MimeType' =>'application/octet-stream'}) |
| 101 | + end |
| 102 | + |
| 103 | + |
| 104 | + # http body (model) |
| 105 | + body = api_client.build_request_body_batch(header_params, form_params, files_content) |
| 106 | + part = "" |
| 107 | + part.concat("PUT".force_encoding('UTF-8')) |
| 108 | + part.concat(" ".force_encoding('UTF-8')) |
| 109 | + part.concat(local_var_path.force_encoding('UTF-8')) |
| 110 | + part.concat(" \r\n".force_encoding('UTF-8')) |
| 111 | + |
| 112 | + 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')) } |
| 113 | + part.concat("\r\n".force_encoding('UTF-8')) |
| 114 | + if body |
| 115 | + if body.is_a?(Hash) |
| 116 | + body.each do |key, value| |
| 117 | + part.concat(value, "\r\n") |
| 118 | + end |
| 119 | + else |
| 120 | + part.concat(body) |
| 121 | + end |
| 122 | + end |
| 123 | + part |
| 124 | + end |
| 125 | + |
| 126 | + def create_http_request(api_client) |
| 127 | + # verify the required parameter 'document' is set |
| 128 | + raise ArgumentError, 'Missing the required parameter document when calling WordsApi.get_all_revisions_online' if api_client.config.client_side_validation && self.document.nil? |
| 129 | + |
| 130 | + # resource path |
| 131 | + local_var_path = '/words/online/get/revisions/getAll'[1..-1] |
| 132 | + local_var_path = local_var_path.sub('//', '/') |
| 133 | + |
| 134 | + # query parameters |
| 135 | + query_params = {} |
| 136 | + query_params[downcase_first_letter('LoadEncoding')] = self.load_encoding unless self.load_encoding.nil? |
| 137 | + query_params[downcase_first_letter('Password')] = self.password unless self.password.nil? |
| 138 | + query_params[downcase_first_letter('EncryptedPassword')] = self.encrypted_password unless self.encrypted_password.nil? |
| 139 | + query_params[downcase_first_letter('OpenTypeSupport')] = self.open_type_support unless self.open_type_support.nil? |
| 140 | + |
| 141 | + # header parameters |
| 142 | + header_params = {} |
| 143 | + # HTTP header 'Content-Type' |
| 144 | + header_params['Content-Type'] = api_client.select_header_content_type(['multipart/form-data']) |
| 145 | + |
| 146 | + # form parameters |
| 147 | + form_params = [] |
| 148 | + files_content = [] |
| 149 | + if self.document.nil? |
| 150 | + raise "Parameter Document is required." |
| 151 | + end |
| 152 | + unless self.document.nil? |
| 153 | + form_params.push({:'Name' => 'document', :'Data' => self.document, :'MimeType' =>'application/octet-stream'}) |
| 154 | + end |
| 155 | + |
| 156 | + body = api_client.build_request_body(header_params, form_params, files_content) |
| 157 | + { |
| 158 | + 'method': :PUT, |
| 159 | + 'path': local_var_path, |
| 160 | + 'header_params': header_params, |
| 161 | + 'query_params': query_params, |
| 162 | + 'body': body, |
| 163 | + 'auth_names': ['JWT'] |
| 164 | + } |
| 165 | + end |
| 166 | + |
| 167 | + # |
| 168 | + # Helper method to convert first letter to downcase |
| 169 | + # |
| 170 | + def downcase_first_letter(str) |
| 171 | + str[0].downcase + str[1..-1] |
| 172 | + end |
| 173 | + |
| 174 | + # Get response type |
| 175 | + def get_response_type |
| 176 | + 'RevisionsResponse' |
| 177 | + end |
| 178 | + end |
| 179 | +end |
0 commit comments