Skip to content

Commit 54f868d

Browse files
committed
Updated sources
1 parent a7207b0 commit 54f868d

21 files changed

Lines changed: 752 additions & 49 deletions

GroupDocs.Conversion.Cloud.Sdk.Test/Api/ConversionApiTests.cs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// </summary>
2424
// --------------------------------------------------------------------------------------------------------------------
2525

26+
using System.IO;
2627
using GroupDocs.Conversion.Cloud.Sdk.Model;
2728
using GroupDocs.Conversion.Cloud.Sdk.Model.Requests;
2829
using GroupDocs.Conversion.Cloud.Sdk.Test.Api.Internal;
@@ -45,16 +46,43 @@ public void ConvertDocumentTest(TestFile testFile, string targetFormat, ConvertO
4546

4647
var settings = new ConvertSettings
4748
{
48-
Storage = string.Empty,
4949
FilePath = filePath,
5050
Format = format,
5151
ConvertOptions = options,
5252
OutputPath = "converted"
5353
};
5454

55-
ConversionApi.ConvertDocument(new ConvertDocumentRequest(settings));
55+
var result = ConversionApi.ConvertDocument(new ConvertDocumentRequest(settings));
5656

57-
Assert.IsTrue(true);
57+
Assert.NotNull(result);
58+
Assert.Greater(result.Count, 0);
59+
var convertedExtension = Path.GetExtension(result[0].Name);
60+
Assert.NotNull(convertedExtension);
61+
Assert.AreEqual(targetFormat, convertedExtension.Substring(1));
62+
}
63+
64+
65+
/// <summary>
66+
/// Test ConvertDocumentTest
67+
/// </summary>
68+
[TestCaseSource(typeof(ConvertOptionsTestCaseBuilder), "Conversions")]
69+
public void ConvertDocumentDownloadTest(TestFile testFile, string targetFormat, ConvertOptions convertOptions)
70+
{
71+
var format = targetFormat;
72+
var options = convertOptions;
73+
var filePath = testFile.FullName;
74+
75+
var settings = new ConvertSettings
76+
{
77+
FilePath = filePath,
78+
Format = format,
79+
ConvertOptions = options
80+
};
81+
82+
var result = ConversionApi.ConvertDocumentDownload(new ConvertDocumentRequest(settings));
83+
84+
Assert.IsNotNull(result);
85+
Assert.Greater(result.Length, 0);
5886
}
5987

6088
/// <summary>

GroupDocs.Conversion.Cloud.Sdk/Api/ConversionApi.cs

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace GroupDocs.Conversion.Cloud.Sdk.Api
2727
{
28+
using System.IO;
2829
using System.Collections.Generic;
2930
using System.Text.RegularExpressions;
3031
using GroupDocs.Conversion.Cloud.Sdk.Client;
@@ -63,35 +64,70 @@ public ConversionApi(Configuration configuration)
6364
requestHandlers.Add(new DebugLogRequestHandler(this.configuration));
6465
requestHandlers.Add(new ApiExceptionRequestHandler());
6566
this.apiInvoker = new ApiInvoker(requestHandlers, this.configuration.Timeout);
66-
}
67+
}
6768

6869
/// <summary>
6970
/// Converts specified input document to format specified in the convertSettings with specified options
7071
/// </summary>
7172
/// <param name="request">Request. <see cref="ConvertDocumentRequest" /></param>
72-
public void ConvertDocument(ConvertDocumentRequest request)
73+
public List<StoredConvertedResult> ConvertDocument(ConvertDocumentRequest request)
7374
{
7475
// verify the required parameter 'convertSettings' is set
75-
if (request.convertSettings == null)
76+
if (request.convertSettings == null)
7677
{
77-
throw new ApiException(400, "Missing required parameter 'convertSettings' when calling ConvertDocument");
78+
throw new ApiException(400,
79+
"Missing required parameter 'convertSettings' when calling ConvertDocument");
7880
}
79-
81+
8082
// create path and map variables
8183
var resourcePath = this.configuration.GetServerUrl() + "/conversion";
8284
resourcePath = Regex
83-
.Replace(resourcePath, "\\*", string.Empty)
84-
.Replace("&amp;", "&")
85-
.Replace("/?", "?");
85+
.Replace(resourcePath, "\\*", string.Empty)
86+
.Replace("&amp;", "&")
87+
.Replace("/?", "?");
8688
var postBody = SerializationHelper.Serialize(request.convertSettings); // http body (model) parameter
87-
this.apiInvoker.InvokeApi(
88-
resourcePath,
89-
"POST",
90-
postBody,
91-
null,
89+
var response = this.apiInvoker.InvokeApi(
90+
resourcePath,
91+
"POST",
92+
postBody,
93+
null,
9294
null);
95+
96+
if (response != null)
97+
{
98+
return (List<StoredConvertedResult>) SerializationHelper.Deserialize(response, typeof(List<StoredConvertedResult>));
99+
}
100+
101+
return null;
93102
}
94103

104+
/// <summary>
105+
/// Converts specified input document to format specified in the convertSettings with specified options and return result as stream
106+
/// </summary>
107+
/// <param name="request">Request. <see cref="ConvertDocumentRequest" /></param>
108+
public Stream ConvertDocumentDownload(ConvertDocumentRequest request)
109+
{
110+
// verify the required parameter 'convertSettings' is set
111+
if (request.convertSettings == null)
112+
{
113+
throw new ApiException(400,
114+
"Missing required parameter 'convertSettings' when calling ConvertDocument");
115+
}
116+
117+
// create path and map variables
118+
var resourcePath = this.configuration.GetServerUrl() + "/conversion";
119+
resourcePath = Regex
120+
.Replace(resourcePath, "\\*", string.Empty)
121+
.Replace("&amp;", "&")
122+
.Replace("/?", "?");
123+
var postBody = SerializationHelper.Serialize(request.convertSettings); // http body (model) parameter
124+
return this.apiInvoker.InvokeBinaryApi(
125+
resourcePath,
126+
"POST",
127+
postBody,
128+
null,
129+
null);
130+
}
95131
/// <summary>
96132
/// Returns all supported conversion types
97133
/// </summary>
@@ -106,7 +142,7 @@ public List<SupportedFormat> GetSupportedConversionTypes(GetSupportedConversionT
106142
.Replace("&amp;", "&")
107143
.Replace("/?", "?");
108144
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "filePath", request.FilePath);
109-
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storage", request.Storage);
145+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storageName", request.StorageName);
110146
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "format", request.format);
111147

112148
var response = this.apiInvoker.InvokeApi(
@@ -115,7 +151,7 @@ public List<SupportedFormat> GetSupportedConversionTypes(GetSupportedConversionT
115151
null,
116152
null,
117153
null);
118-
154+
119155
if (response != null)
120156
{
121157
return (List<SupportedFormat>)SerializationHelper.Deserialize(response, typeof(List<SupportedFormat>));
@@ -226,12 +262,12 @@ public GetSupportedConversionTypesRequest()
226262
/// Initializes a new instance of the <see cref="GetSupportedConversionTypesRequest"/> class.
227263
/// </summary>
228264
/// <param name="filePath">Absolute path to a document in the storage</param>
229-
/// <param name="storage">Storage which contains the document</param>
265+
/// <param name="storageName">StorageName which contains the document</param>
230266
/// <param name="format">If provided only supported conversions for specified format will be returned</param>
231-
public GetSupportedConversionTypesRequest(string filePath = null, string storage = null, string format = null)
267+
public GetSupportedConversionTypesRequest(string filePath = null, string storageName = null, string format = null)
232268
{
233269
this.FilePath = filePath;
234-
this.Storage = storage;
270+
this.StorageName = storageName;
235271
this.format = format;
236272
}
237273

@@ -241,9 +277,9 @@ public GetSupportedConversionTypesRequest(string filePath = null, string storage
241277
public string FilePath { get; set; }
242278

243279
/// <summary>
244-
/// Storage which contains the document
280+
/// StorageName which contains the document
245281
/// </summary>
246-
public string Storage { get; set; }
282+
public string StorageName { get; set; }
247283

248284
/// <summary>
249285
/// If provided only supported conversions for specified format will be returned

GroupDocs.Conversion.Cloud.Sdk/Api/FileApi.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace GroupDocs.Conversion.Cloud.Sdk.Api
2727
{
28+
using System.IO;
2829
using System.Collections.Generic;
2930
using System.Text.RegularExpressions;
3031
using GroupDocs.Conversion.Cloud.Sdk.Client;
@@ -63,7 +64,7 @@ public FileApi(Configuration configuration)
6364
requestHandlers.Add(new DebugLogRequestHandler(this.configuration));
6465
requestHandlers.Add(new ApiExceptionRequestHandler());
6566
this.apiInvoker = new ApiInvoker(requestHandlers, this.configuration.Timeout);
66-
}
67+
}
6768

6869
/// <summary>
6970
/// Copy file
@@ -102,7 +103,6 @@ public void CopyFile(CopyFileRequest request)
102103
null,
103104
null);
104105
}
105-
106106
/// <summary>
107107
/// Delete file
108108
/// </summary>
@@ -132,7 +132,6 @@ public void DeleteFile(DeleteFileRequest request)
132132
null,
133133
null);
134134
}
135-
136135
/// <summary>
137136
/// Download file
138137
/// </summary>
@@ -163,7 +162,6 @@ public System.IO.Stream DownloadFile(DownloadFileRequest request)
163162
null,
164163
null);
165164
}
166-
167165
/// <summary>
168166
/// Move file
169167
/// </summary>
@@ -201,7 +199,6 @@ public void MoveFile(MoveFileRequest request)
201199
null,
202200
null);
203201
}
204-
205202
/// <summary>
206203
/// Upload file
207204
/// </summary>
@@ -242,7 +239,7 @@ public FilesUploadResult UploadFile(UploadFileRequest request)
242239
null,
243240
null,
244241
formParams);
245-
242+
246243
if (response != null)
247244
{
248245
return (FilesUploadResult)SerializationHelper.Deserialize(response, typeof(FilesUploadResult));

GroupDocs.Conversion.Cloud.Sdk/Api/FolderApi.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace GroupDocs.Conversion.Cloud.Sdk.Api
2727
{
28+
using System.IO;
2829
using System.Collections.Generic;
2930
using System.Text.RegularExpressions;
3031
using GroupDocs.Conversion.Cloud.Sdk.Client;
@@ -63,7 +64,7 @@ public FolderApi(Configuration configuration)
6364
requestHandlers.Add(new DebugLogRequestHandler(this.configuration));
6465
requestHandlers.Add(new ApiExceptionRequestHandler());
6566
this.apiInvoker = new ApiInvoker(requestHandlers, this.configuration.Timeout);
66-
}
67+
}
6768

6869
/// <summary>
6970
/// Copy folder
@@ -101,7 +102,6 @@ public void CopyFolder(CopyFolderRequest request)
101102
null,
102103
null);
103104
}
104-
105105
/// <summary>
106106
/// Create the folder
107107
/// </summary>
@@ -130,7 +130,6 @@ public void CreateFolder(CreateFolderRequest request)
130130
null,
131131
null);
132132
}
133-
134133
/// <summary>
135134
/// Delete folder
136135
/// </summary>
@@ -160,7 +159,6 @@ public void DeleteFolder(DeleteFolderRequest request)
160159
null,
161160
null);
162161
}
163-
164162
/// <summary>
165163
/// Get all files and folders within a folder
166164
/// </summary>
@@ -189,15 +187,14 @@ public FilesList GetFilesList(GetFilesListRequest request)
189187
null,
190188
null,
191189
null);
192-
190+
193191
if (response != null)
194192
{
195193
return (FilesList)SerializationHelper.Deserialize(response, typeof(FilesList));
196194
}
197195

198196
return null;
199197
}
200-
201198
/// <summary>
202199
/// Move folder
203200
/// </summary>

GroupDocs.Conversion.Cloud.Sdk/Api/StorageApi.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace GroupDocs.Conversion.Cloud.Sdk.Api
2727
{
28+
using System.IO;
2829
using System.Collections.Generic;
2930
using System.Text.RegularExpressions;
3031
using GroupDocs.Conversion.Cloud.Sdk.Client;
@@ -63,7 +64,7 @@ public StorageApi(Configuration configuration)
6364
requestHandlers.Add(new DebugLogRequestHandler(this.configuration));
6465
requestHandlers.Add(new ApiExceptionRequestHandler());
6566
this.apiInvoker = new ApiInvoker(requestHandlers, this.configuration.Timeout);
66-
}
67+
}
6768

6869
/// <summary>
6970
/// Get disc usage
@@ -86,15 +87,14 @@ public DiscUsage GetDiscUsage(GetDiscUsageRequest request)
8687
null,
8788
null,
8889
null);
89-
90+
9091
if (response != null)
9192
{
9293
return (DiscUsage)SerializationHelper.Deserialize(response, typeof(DiscUsage));
9394
}
9495

9596
return null;
9697
}
97-
9898
/// <summary>
9999
/// Get file versions
100100
/// </summary>
@@ -123,15 +123,14 @@ public FileVersions GetFileVersions(GetFileVersionsRequest request)
123123
null,
124124
null,
125125
null);
126-
126+
127127
if (response != null)
128128
{
129129
return (FileVersions)SerializationHelper.Deserialize(response, typeof(FileVersions));
130130
}
131131

132132
return null;
133133
}
134-
135134
/// <summary>
136135
/// Check if file or folder exists
137136
/// </summary>
@@ -161,15 +160,14 @@ public ObjectExist ObjectExists(ObjectExistsRequest request)
161160
null,
162161
null,
163162
null);
164-
163+
165164
if (response != null)
166165
{
167166
return (ObjectExist)SerializationHelper.Deserialize(response, typeof(ObjectExist));
168167
}
169168

170169
return null;
171170
}
172-
173171
/// <summary>
174172
/// Check if storage exists
175173
/// </summary>
@@ -197,7 +195,7 @@ public StorageExist StorageExists(StorageExistsRequest request)
197195
null,
198196
null,
199197
null);
200-
198+
201199
if (response != null)
202200
{
203201
return (StorageExist)SerializationHelper.Deserialize(response, typeof(StorageExist));

0 commit comments

Comments
 (0)