|
| 1 | +// -------------------------------------------------------------------------------------------------------------------- |
| 2 | +// <copyright company="Aspose" file="LoadWebDocumentOnlineRequest.cs"> |
| 3 | +// Copyright (c) 2025 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 | +namespace Aspose.Words.Cloud.Sdk.Model.Requests |
| 27 | +{ |
| 28 | + using System; |
| 29 | + using System.Collections.Generic; |
| 30 | + using System.IO; |
| 31 | + using System.Net.Http; |
| 32 | + using System.Text.RegularExpressions; |
| 33 | + using System.Threading.Tasks; |
| 34 | + using System.Security.Cryptography; |
| 35 | + using Aspose.Words.Cloud.Sdk.Model; |
| 36 | + using Aspose.Words.Cloud.Sdk.Model.Responses; |
| 37 | + |
| 38 | + /// <summary> |
| 39 | + /// Request model for <see cref="Aspose.Words.Cloud.Sdk.Api.WordsApi.LoadWebDocumentOnline" /> operation. |
| 40 | + /// </summary> |
| 41 | + public class LoadWebDocumentOnlineRequest : IRequestModel |
| 42 | + { |
| 43 | + /// <summary> |
| 44 | + /// Initializes a new instance of the <see cref="LoadWebDocumentOnlineRequest"/> class. |
| 45 | + /// </summary> |
| 46 | + public LoadWebDocumentOnlineRequest() |
| 47 | + { |
| 48 | + } |
| 49 | + |
| 50 | + /// <summary> |
| 51 | + /// Initializes a new instance of the <see cref="LoadWebDocumentOnlineRequest"/> class. |
| 52 | + /// </summary> |
| 53 | + /// <param name="data">The properties of data downloading.</param> |
| 54 | + public LoadWebDocumentOnlineRequest(LoadWebDocumentData data) |
| 55 | + { |
| 56 | + this.Data = data; |
| 57 | + } |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// The properties of data downloading. |
| 61 | + /// </summary> |
| 62 | + public LoadWebDocumentData Data { get; set; } |
| 63 | + |
| 64 | + /// <summary> |
| 65 | + /// Creates the http request based on this request. |
| 66 | + /// </summary> |
| 67 | + /// <param name="configuration">SDK configuration.</param> |
| 68 | + /// <param name="encryptor">password encyptor.</param> |
| 69 | + /// <returns>The http request instance.</returns> |
| 70 | + public async Task<HttpRequestMessage> CreateHttpRequest(Configuration configuration, IEncryptor encryptor) |
| 71 | + { |
| 72 | + // verify the required parameter 'data' is set |
| 73 | + if (this.Data == null) |
| 74 | + { |
| 75 | + throw new ApiException(400, "Missing required parameter 'data' when calling LoadWebDocumentOnline"); |
| 76 | + } |
| 77 | + |
| 78 | + this.Data?.Validate(); |
| 79 | + |
| 80 | + var path = configuration.GetApiRootUrl() + "/words/online/put/loadWebDocument"; |
| 81 | + path = Regex |
| 82 | + .Replace(path, "\\*", string.Empty) |
| 83 | + .Replace("&", "&") |
| 84 | + .Replace("/?", "?"); |
| 85 | + |
| 86 | + var formData = new List< Tuple<string, object> >(); |
| 87 | + var result = new HttpRequestMessage(HttpMethod.Put, path); |
| 88 | + if (this.Data != null) |
| 89 | + { |
| 90 | + formData.Add(new Tuple<string, object>("Data", this.Data)); |
| 91 | + } |
| 92 | + |
| 93 | + result.Content = await ApiInvoker.GetRequestContent(formData, encryptor); |
| 94 | + return result; |
| 95 | + } |
| 96 | + |
| 97 | + /// <summary> |
| 98 | + /// Deserialize response object. |
| 99 | + /// </summary> |
| 100 | + /// <param name="message">Response message.</param> |
| 101 | + /// <returns>Response type.</returns> |
| 102 | + public async Task<object> DeserializeResponse(HttpResponseMessage message) |
| 103 | + { |
| 104 | + var multipart = await ApiInvoker.ToMultipartForm(message); |
| 105 | + return new LoadWebDocumentOnlineResponse( |
| 106 | + model: (SaveResponse)SerializationHelper.Deserialize( |
| 107 | + await new StreamReader(multipart["Model"].Content, System.Text.Encoding.UTF8).ReadToEndAsync(), |
| 108 | + typeof(SaveResponse)), |
| 109 | + document: await SerializationHelper.DeserializeFilesCollection(multipart["Document"]) |
| 110 | + ); |
| 111 | + } |
| 112 | + } |
| 113 | +} |
0 commit comments