Skip to content

Commit 3722d34

Browse files
authored
Merge branch 'cloudconvert:master' into convert-to-system-text-json
2 parents 0af76e1 + d842282 commit 3722d34

3 files changed

Lines changed: 48 additions & 3 deletions

File tree

CloudConvert.API/CloudConvert.API.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<AssemblyName>CloudConvert.API</AssemblyName>
66
<RootNamespace>CloudConvert.API</RootNamespace>
77
<Description>Official SDK for the CloudConvert API</Description>
8-
<Version>1.2.0</Version>
8+
<Version>1.3.0</Version>
99
<PackageProjectUrl>https://github.com/cloudconvert/cloudconvert-dotnet</PackageProjectUrl>
1010
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1111
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

CloudConvert.API/CloudConvertAPI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public interface ICloudConvertAPI
2626
#region Tasks
2727
Task<ListResponse<TaskResponse>> GetAllTasksAsync(TaskListFilter jobFilter);
2828
Task<Response<TaskResponse>> CreateTaskAsync<T>(string operation, T request);
29-
Task<Response<TaskResponse>> GetTaskAsync(string id, string[] include = null);
29+
Task<Response<TaskResponse>> GetTaskAsync(string id, string include = null);
3030
Task<Response<TaskResponse>> WaitTaskAsync(string id);
3131
Task DeleteTaskAsync(string id);
3232
#endregion
@@ -189,7 +189,7 @@ private HttpRequestMessage GetMultipartFormDataRequest(string endpoint, HttpMeth
189189
/// <param name="id"></param>
190190
/// <param name="include"></param>
191191
/// <returns></returns>
192-
public Task<Response<TaskResponse>> GetTaskAsync(string id, string[] include = null) => _restHelper.RequestAsync<Response<TaskResponse>>(GetRequest($"{_apiUrl}/tasks/{id}?include={include}", HttpMethod.Get));
192+
public Task<Response<TaskResponse>> GetTaskAsync(string id, string include = null) => _restHelper.RequestAsync<Response<TaskResponse>>(GetRequest($"{_apiUrl}/tasks/{id}?include={include}", HttpMethod.Get));
193193

194194
/// <summary>
195195
/// Wait until the task status is finished or error. This makes the request block until the task has been completed. Requires the task.read scope.

CloudConvert.Test/IntegrationTests.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using CloudConvert.API.Models.JobModels;
99
using System;
1010
using System.Net.Http;
11+
using CloudConvert.API.Models.TaskOperations;
12+
using System.Collections.Generic;
1113

1214
namespace CloudConvert.Test
1315
{
@@ -83,6 +85,49 @@ public async Task CreateJob(string streamingMethod)
8385
await File.WriteAllBytesAsync(fileExport.Filename, fileBytes);
8486
}
8587

88+
89+
[Test]
90+
public async Task CreateJobWithOptions()
91+
{
92+
var job = await _cloudConvertAPI.CreateJobAsync(new JobCreateRequest
93+
{
94+
Tasks = new
95+
{
96+
import_it = new ImportUploadCreateRequest(),
97+
convert_it = new ConvertCreateRequest
98+
{
99+
Input = "import_it",
100+
Input_Format = "pdf",
101+
Output_Format = "jpg",
102+
Options = new Dictionary<string, object> {
103+
{ "width", 800 },
104+
{ "height", 600 },
105+
{ "fit", "max" }
106+
}
107+
}
108+
},
109+
Tag = "integration-test-convert-with-options"
110+
});
111+
112+
var uploadTask = job.Data.Tasks.FirstOrDefault(t => t.Name == "import_it");
113+
114+
var path = AppDomain.CurrentDomain.BaseDirectory + @"TestFiles/input.pdf";
115+
116+
byte[] file = File.ReadAllBytes(path);
117+
await _cloudConvertAPI.UploadAsync(uploadTask.Result.Form.Url.ToString(), file, "input.pdf", uploadTask.Result.Form.Parameters);
118+
119+
120+
// get created convert task
121+
122+
var convertTask = await _cloudConvertAPI.GetTaskAsync(job.Data.Tasks.FirstOrDefault(t => t.Name == "convert_it").Id, "payload");
123+
var payload = ((Newtonsoft.Json.Linq.JObject)convertTask.Data.Payload).ToObject<Dictionary<string, object>>();
124+
Assert.IsNotNull(payload);
125+
Assert.AreEqual(800, payload["width"]);
126+
Assert.AreEqual(600, payload["height"]);
127+
Assert.AreEqual("max", payload["fit"]);
128+
129+
}
130+
86131
[TestCase("stream")]
87132
[TestCase("bytes")]
88133
public async Task CreateTask(string streamingMethod)

0 commit comments

Comments
 (0)