Skip to content

Commit 4a14c53

Browse files
committed
Updated sources
1 parent af206ba commit 4a14c53

14 files changed

Lines changed: 502 additions & 99 deletions

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public void AuthErrorWhenAppSidNotFoundTest()
4747
ApiBaseUrl = Config.ApiBaseUrl
4848
};
4949

50-
var conversionApi = new ConversionApi(conversionConfig);
50+
var infoApi = new InfoApi(conversionConfig);
5151

52-
var ex = Assert.Throws<ApiException>(() => { conversionApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest()); });
52+
var ex = Assert.Throws<ApiException>(() => { infoApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest()); });
5353

5454
Assert.AreEqual("invalid_client", ex.Message);
5555
}
@@ -68,11 +68,11 @@ public void AuthErrorWhenAppKeyNotFoundTest()
6868
ApiBaseUrl = Config.ApiBaseUrl
6969
};
7070

71-
var conversionApi = new ConversionApi(conversionConfig);
71+
var infoApi = new InfoApi(conversionConfig);
7272

7373
var ex = Assert.Throws<ApiException>(() =>
7474
{
75-
conversionApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest());
75+
infoApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest());
7676
});
7777

7878
Assert.AreEqual("invalid_client", ex.Message);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public class BaseApiTest
4343
private readonly string _appKey = Config.AppKey;
4444
private readonly string _apiBaseUrl = Config.ApiBaseUrl;
4545

46-
protected ConversionApi ConversionApi;
46+
protected ConvertApi ConvertApi;
47+
protected InfoApi InfoApi;
4748
protected FileApi FileApi;
4849
protected FolderApi FolderApi;
4950
protected StorageApi StorageApi;
@@ -56,7 +57,8 @@ public void BeforeAllTests()
5657
ApiBaseUrl = _apiBaseUrl
5758
};
5859

59-
ConversionApi = new ConversionApi(config);
60+
ConvertApi = new ConvertApi(config);
61+
InfoApi = new InfoApi(config);
6062
FileApi = new FileApi(config);
6163
FolderApi = new FolderApi(config);
6264
StorageApi = new StorageApi(config);

GroupDocs.Conversion.Cloud.Sdk.Test/Api/ConversionApiTests.cs renamed to GroupDocs.Conversion.Cloud.Sdk.Test/Api/ConvertApiTests.cs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace GroupDocs.Conversion.Cloud.Sdk.Test.Api
3232
{
3333
using NUnit.Framework;
3434

35-
public class ConversionApiTests : BaseApiTest
35+
public class ConvertApiTests : BaseApiTest
3636
{
3737
/// <summary>
3838
/// Test ConvertDocumentTest
@@ -52,7 +52,7 @@ public void ConvertDocumentTest(TestFile testFile, string targetFormat, ConvertO
5252
OutputPath = "converted"
5353
};
5454

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

5757
Assert.NotNull(result);
5858
Assert.Greater(result.Count, 0);
@@ -79,26 +79,10 @@ public void ConvertDocumentDownloadTest(TestFile testFile, string targetFormat,
7979
ConvertOptions = options
8080
};
8181

82-
var result = ConversionApi.ConvertDocumentDownload(new ConvertDocumentRequest(settings));
82+
var result = ConvertApi.ConvertDocumentDownload(new ConvertDocumentRequest(settings));
8383

8484
Assert.IsNotNull(result);
8585
Assert.Greater(result.Length, 0);
8686
}
87-
88-
/// <summary>
89-
/// Test GetSupportedConversionTypes
90-
/// </summary>
91-
[Test]
92-
public void GetSupportedConversionTypesTest()
93-
{
94-
var response = ConversionApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest());
95-
96-
Assert.IsTrue(response.Count > 0);
97-
foreach (var entry in response)
98-
{
99-
Assert.IsNotEmpty(entry.SourceFormat);
100-
Assert.IsTrue(entry.TargetFormats.Count > 0);
101-
}
102-
}
10387
}
10488
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose Pty Ltd">
3+
// Copyright (c) 2003-2019 Aspose Pty Ltd
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+
using GroupDocs.Conversion.Cloud.Sdk.Model.Requests;
27+
using GroupDocs.Conversion.Cloud.Sdk.Test.Api.Internal;
28+
29+
namespace GroupDocs.Conversion.Cloud.Sdk.Test.Api
30+
{
31+
using NUnit.Framework;
32+
33+
public class InfoApiTests : BaseApiTest
34+
{
35+
/// <summary>
36+
/// Test GetSupportedConversionTypes
37+
/// </summary>
38+
[Test]
39+
public void GetSupportedConversionTypesTest()
40+
{
41+
var response = InfoApi.GetSupportedConversionTypes(new GetSupportedConversionTypesRequest());
42+
43+
Assert.IsTrue(response.Count > 0);
44+
foreach (var entry in response)
45+
{
46+
Assert.IsNotEmpty(entry.SourceFormat);
47+
Assert.IsTrue(entry.TargetFormats.Count > 0);
48+
}
49+
}
50+
51+
/// <summary>
52+
/// Test GetSupportedConversionTypes
53+
/// </summary>
54+
[Test]
55+
public void GetDocumentMetadataTest()
56+
{
57+
var response = InfoApi.GetDocumentMetadata(new GetDocumentMetadataRequest(TestFiles.FourPagesDocx.FullName));
58+
59+
Assert.AreEqual(4, response.PageCount);
60+
}
61+
}
62+
}

GroupDocs.Conversion.Cloud.Sdk.Test/GroupDocs.Conversion.Cloud.Sdk.Test.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ OpenAPI spec version: 1.0
5151
<ItemGroup>
5252
<Compile Include="Api\BaseApiTest.cs" />
5353
<Compile Include="Api\AuthApiTests.cs" />
54-
<Compile Include="Api\ConversionApiTests.cs" />
54+
<Compile Include="Api\ConvertApiTests.cs" />
5555
<Compile Include="Api\ConvertOptionsTestCaseBuilder.cs" />
5656
<Compile Include="Api\FolderApiTests.cs" />
57+
<Compile Include="Api\InfoApiTests.cs" />
5758
<Compile Include="Api\Internal\TestFile.cs" />
5859
<Compile Include="Api\Internal\TestFiles.cs" />
5960
<Compile Include="Api\FileApiTests.cs" />
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose Pty Ltd" file="ConvertApi.cs">
3+
// Copyright (c) 2003-2019 Aspose Pty Ltd
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 GroupDocs.Conversion.Cloud.Sdk.Api
27+
{
28+
using System.IO;
29+
using System.Collections.Generic;
30+
using System.Text.RegularExpressions;
31+
using GroupDocs.Conversion.Cloud.Sdk.Client;
32+
using GroupDocs.Conversion.Cloud.Sdk.Client.RequestHandlers;
33+
using GroupDocs.Conversion.Cloud.Sdk.Model;
34+
using GroupDocs.Conversion.Cloud.Sdk.Model.Requests;
35+
36+
/// <summary>
37+
/// GroupDocs.Conversion Cloud API.
38+
/// </summary>
39+
public class ConvertApi
40+
{
41+
private readonly ApiInvoker apiInvoker;
42+
private readonly Configuration configuration;
43+
44+
/// <summary>
45+
/// Initializes a new instance of the <see cref="ConvertApi"/> class.
46+
/// </summary>
47+
/// <param name="appSid">Application identifier (App SID)</param>
48+
/// <param name="appKey">Application private key (App Key)</param>
49+
public ConvertApi(string appSid, string appKey)
50+
: this(new Configuration(appSid, appKey))
51+
{
52+
}
53+
54+
/// <summary>
55+
/// Initializes a new instance of the <see cref="ConvertApi"/> class.
56+
/// </summary>
57+
/// <param name="configuration">Configuration settings</param>
58+
public ConvertApi(Configuration configuration)
59+
{
60+
this.configuration = configuration;
61+
62+
var requestHandlers = new List<IRequestHandler>();
63+
requestHandlers.Add(new AuthRequestHandler(this.configuration));
64+
requestHandlers.Add(new DebugLogRequestHandler(this.configuration));
65+
requestHandlers.Add(new ApiExceptionRequestHandler());
66+
this.apiInvoker = new ApiInvoker(requestHandlers, this.configuration.Timeout);
67+
}
68+
69+
/// <summary>
70+
/// Converts specified input document to format specified in the convertSettings with specified options
71+
/// </summary>
72+
/// <param name="request">Request. <see cref="ConvertDocumentRequest" /></param>
73+
public List<StoredConvertedResult> ConvertDocument(ConvertDocumentRequest request)
74+
{
75+
// verify the required parameter 'convertSettings' is set
76+
if (request.convertSettings == null)
77+
{
78+
throw new ApiException(400,
79+
"Missing required parameter 'convertSettings' when calling ConvertDocument");
80+
}
81+
82+
// create path and map variables
83+
var resourcePath = this.configuration.GetServerUrl() + "/conversion";
84+
resourcePath = Regex
85+
.Replace(resourcePath, "\\*", string.Empty)
86+
.Replace("&amp;", "&")
87+
.Replace("/?", "?");
88+
var postBody = SerializationHelper.Serialize(request.convertSettings); // http body (model) parameter
89+
var response = this.apiInvoker.InvokeApi(
90+
resourcePath,
91+
"POST",
92+
postBody,
93+
null,
94+
null);
95+
96+
if (response != null)
97+
{
98+
return (List<StoredConvertedResult>) SerializationHelper.Deserialize(response, typeof(List<StoredConvertedResult>));
99+
}
100+
101+
return null;
102+
}
103+
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+
}
131+
}
132+
}
133+
// --------------------------------------------------------------------------------------------------------------------
134+
// <copyright company="Aspose Pty Ltd" file="ConvertDocumentRequest.cs">
135+
// Copyright (c) 2003-2019 Aspose Pty Ltd
136+
// </copyright>
137+
// <summary>
138+
// Permission is hereby granted, free of charge, to any person obtaining a copy
139+
// of this software and associated documentation files (the "Software"), to deal
140+
// in the Software without restriction, including without limitation the rights
141+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
142+
// copies of the Software, and to permit persons to whom the Software is
143+
// furnished to do so, subject to the following conditions:
144+
//
145+
// The above copyright notice and this permission notice shall be included in all
146+
// copies or substantial portions of the Software.
147+
//
148+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
149+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
150+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
151+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
152+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
153+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
154+
// SOFTWARE.
155+
// </summary>
156+
// --------------------------------------------------------------------------------------------------------------------
157+
158+
namespace GroupDocs.Conversion.Cloud.Sdk.Model.Requests
159+
{
160+
using GroupDocs.Conversion.Cloud.Sdk.Model;
161+
162+
/// <summary>
163+
/// Request model for <see cref="GroupDocs.Conversion.Cloud.Sdk.Api.ConvertApi.ConvertDocument" /> operation.
164+
/// </summary>
165+
public class ConvertDocumentRequest
166+
{
167+
/// <summary>
168+
/// Initializes a new instance of the <see cref="ConvertDocumentRequest"/> class.
169+
/// </summary>
170+
public ConvertDocumentRequest()
171+
{
172+
}
173+
174+
/// <summary>
175+
/// Initializes a new instance of the <see cref="ConvertDocumentRequest"/> class.
176+
/// </summary>
177+
/// <param name="convertSettings"></param>
178+
public ConvertDocumentRequest(ConvertSettings convertSettings)
179+
{
180+
this.convertSettings = convertSettings;
181+
}
182+
183+
/// <summary>
184+
/// Gets or sets convertSettings
185+
/// </summary>
186+
public ConvertSettings convertSettings { get; set; }
187+
}
188+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public FilesUploadResult UploadFile(UploadFileRequest request)
235235

236236
var response = this.apiInvoker.InvokeApi(
237237
resourcePath,
238-
"POST",
238+
"PUT",
239239
null,
240240
null,
241241
formParams);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void CreateFolder(CreateFolderRequest request)
125125

126126
this.apiInvoker.InvokeApi(
127127
resourcePath,
128-
"POST",
128+
"PUT",
129129
null,
130130
null,
131131
null);

0 commit comments

Comments
 (0)