diff --git a/CloudConvert.API/CloudConvert.API.csproj b/CloudConvert.API/CloudConvert.API.csproj
index f2c4d9e..c11fe6b 100644
--- a/CloudConvert.API/CloudConvert.API.csproj
+++ b/CloudConvert.API/CloudConvert.API.csproj
@@ -18,7 +18,6 @@
-
diff --git a/CloudConvert.API/CloudConvertAPI.cs b/CloudConvert.API/CloudConvertAPI.cs
index 310be86..4c44ae5 100644
--- a/CloudConvert.API/CloudConvertAPI.cs
+++ b/CloudConvert.API/CloudConvertAPI.cs
@@ -6,8 +6,7 @@
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
+using System.Text.Json;
using CloudConvert.API.Models.JobModels;
using CloudConvert.API.Models.TaskModels;
using CloudConvert.API.Models;
@@ -74,16 +73,17 @@ public CloudConvertAPI(string url, string api_key)
private HttpRequestMessage GetRequest(string endpoint, HttpMethod method, object model = null)
{
var request = new HttpRequestMessage { RequestUri = new Uri(endpoint), Method = method };
-
+
if (model != null)
{
- var content = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
+ var content = new StringContent(JsonSerializer.Serialize(model, DefaultJsonSerializerOptions.SerializerOptions), Encoding.UTF8, "application/json");
request.Content = content;
}
-
+
+
request.Headers.Add("Authorization", _api_key);
- request.Headers.Add("User-Agent", "cloudconvert-dotnet/v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " (https://github.com/cloudconvert/cloudconvert-dotnet)");
-
+ request.Headers.Add("User-Agent", "cloudconvert-dotnet/v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " (https://github.com/cloudconvert/cloudconvert-dotnet)");
+
return request;
}
@@ -100,7 +100,7 @@ private HttpRequestMessage GetMultipartFormDataRequest(string endpoint, HttpMeth
}
}
- fileContent.Headers.Add("Content-Disposition", $"form-data; name=\"file\"; filename=\"{ new string(Encoding.UTF8.GetBytes(fileName).Select(b => (char)b).ToArray())}\"");
+ fileContent.Headers.Add("Content-Disposition", $"form-data; name=\"file\"; filename=\"{new string(Encoding.UTF8.GetBytes(fileName).Select(b => (char)b).ToArray())}\"");
content.Add(fileContent);
request.Content = content;
@@ -225,10 +225,10 @@ private HttpRequestMessage GetMultipartFormDataRequest(string endpoint, HttpMeth
public string CreateSignedUrl(string baseUrl, string signingSecret, JobCreateRequest job, string cacheKey = null)
{
string url = baseUrl;
- string jobJson = JsonConvert.SerializeObject(job);
+ string jobJson = JsonSerializer.Serialize(job, DefaultJsonSerializerOptions.SerializerOptions);
string base64Job = System.Convert.ToBase64String(Encoding.ASCII.GetBytes(jobJson)).TrimEnd(base64Padding).Replace('+', '-').Replace('/', '_');
-
- url += "?job=" + base64Job;
+
+ url += "?job=" + base64Job;
if(cacheKey != null) {
url += "&cache_key=" + cacheKey;
@@ -254,14 +254,47 @@ private string HashHMAC(string key, string message)
return BitConverter.ToString(hash).Replace("-", "").ToLower();
}
+ // FIXME
private Dictionary GetParameters(object parameters)
{
- var attributes = ((JToken)parameters).ToList();
- Dictionary dictionaryParameters = new Dictionary();
- foreach (JToken attribute in attributes)
+ var dictionaryParameters = new Dictionary();
+
+ if (parameters != null)
{
- JProperty jProperty = attribute.ToObject();
- dictionaryParameters.Add(jProperty.Name, jProperty.Value.ToString());
+ // Serialize the input object to JSON.
+ string json = JsonSerializer.Serialize(parameters, DefaultJsonSerializerOptions.SerializerOptions);
+
+ // Parse the JSON using JsonDocument.
+ using (var doc = JsonDocument.Parse(json))
+ {
+ var root = doc.RootElement;
+ if (root.ValueKind == JsonValueKind.Object)
+ {
+ foreach (JsonProperty prop in root.EnumerateObject())
+ {
+ string valueStr;
+ // Replicate JToken.ToString() behavior:
+ // For string values, return the unquoted string.
+ // For objects and arrays, serialize them to JSON.
+ // Otherwise, use the default ToString().
+ switch (prop.Value.ValueKind)
+ {
+ case JsonValueKind.String:
+ valueStr = prop.Value.GetString();
+ break;
+ case JsonValueKind.Object:
+ case JsonValueKind.Array:
+ valueStr = JsonSerializer.Serialize(prop.Value, DefaultJsonSerializerOptions.SerializerOptions);
+ break;
+ default:
+ valueStr = prop.Value.ToString();
+ break;
+ }
+
+ dictionaryParameters[prop.Name] = valueStr;
+ }
+ }
+ }
}
return dictionaryParameters;
diff --git a/CloudConvert.API/DefaultJsonSerializerOptions.cs b/CloudConvert.API/DefaultJsonSerializerOptions.cs
new file mode 100644
index 0000000..acd337c
--- /dev/null
+++ b/CloudConvert.API/DefaultJsonSerializerOptions.cs
@@ -0,0 +1,14 @@
+using System.Text.Json.Serialization;
+using System.Text.Json;
+
+namespace CloudConvert.API
+{
+ public class DefaultJsonSerializerOptions
+ {
+ public static readonly JsonSerializerOptions SerializerOptions = new()
+ {
+ Converters = { new JsonStringEnumConverter() },
+ DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
+ };
+ }
+}
diff --git a/CloudConvert.API/Models/ErrorResponse.cs b/CloudConvert.API/Models/ErrorResponse.cs
index 008f29b..a3739b5 100644
--- a/CloudConvert.API/Models/ErrorResponse.cs
+++ b/CloudConvert.API/Models/ErrorResponse.cs
@@ -1,16 +1,16 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models
{
public partial class ErrorResponse
{
- [JsonProperty("message")]
+ [JsonPropertyName("message")]
public string Message { get; set; }
- [JsonProperty("code")]
+ [JsonPropertyName("code")]
public string Code { get; set; }
- [JsonProperty("errors")]
+ [JsonPropertyName("errors")]
public object Errors { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ExportOperations/ExportAzureBlobCreateRequest.cs b/CloudConvert.API/Models/ExportOperations/ExportAzureBlobCreateRequest.cs
index 70dbc6b..816e802 100644
--- a/CloudConvert.API/Models/ExportOperations/ExportAzureBlobCreateRequest.cs
+++ b/CloudConvert.API/Models/ExportOperations/ExportAzureBlobCreateRequest.cs
@@ -1,35 +1,35 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ExportOperations
{
public class ExportAzureBlobCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "export/azure/blob";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "export/azure/blob";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
- [JsonProperty("storage_account")]
+ [JsonPropertyName("storage_account")]
public string Storage_Account { get; set; }
- [JsonProperty("storage_access_key", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("storage_access_key")]
public string Storage_Access_Key { get; set; }
- [JsonProperty("sas_token", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("sas_token")]
public string Sas_Token { get; set; }
- [JsonProperty("container")]
+ [JsonPropertyName("container")]
public string Container { get; set; }
- [JsonProperty("blob", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("blob")]
public string Blob { get; set; }
- [JsonProperty("blob_prefix", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("blob_prefix")]
public string Blob_Prefix { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ExportOperations/ExportGoogleCloudStorageCreateRequest.cs b/CloudConvert.API/Models/ExportOperations/ExportGoogleCloudStorageCreateRequest.cs
index 3d6db10..04b0796 100644
--- a/CloudConvert.API/Models/ExportOperations/ExportGoogleCloudStorageCreateRequest.cs
+++ b/CloudConvert.API/Models/ExportOperations/ExportGoogleCloudStorageCreateRequest.cs
@@ -1,35 +1,35 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ExportOperations
{
public class ExportGoogleCloudStorageCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "export/google-cloud-storage";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "export/google-cloud-storage";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
- [JsonProperty("project_id")]
+ [JsonPropertyName("project_id")]
public string ProjectId { get; set; }
- [JsonProperty("bucket")]
+ [JsonPropertyName("bucket")]
public string Bucket { get; set; }
- [JsonProperty("client_email")]
+ [JsonPropertyName("client_email")]
public string Client_Email { get; set; }
- [JsonProperty("private_key")]
+ [JsonPropertyName("private_key")]
public string Private_Key { get; set; }
- [JsonProperty("file", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("file")]
public string File { get; set; }
- [JsonProperty("file_prefix", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("file_prefix")]
public string File_Prefix { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ExportOperations/ExportOpenStackCreateRequest.cs b/CloudConvert.API/Models/ExportOperations/ExportOpenStackCreateRequest.cs
index a4214de..a004e44 100644
--- a/CloudConvert.API/Models/ExportOperations/ExportOpenStackCreateRequest.cs
+++ b/CloudConvert.API/Models/ExportOperations/ExportOpenStackCreateRequest.cs
@@ -1,38 +1,38 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ExportOperations
{
public class ExportOpenStackCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "export/openstack";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "export/openstack";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
- [JsonProperty("auth_url")]
+ [JsonPropertyName("auth_url")]
public string Auth_Url { get; set; }
- [JsonProperty("username")]
+ [JsonPropertyName("username")]
public string Username { get; set; }
- [JsonProperty("password")]
+ [JsonPropertyName("password")]
public string Password { get; set; }
- [JsonProperty("region")]
+ [JsonPropertyName("region")]
public string Region { get; set; }
- [JsonProperty("container")]
+ [JsonPropertyName("container")]
public string Container { get; set; }
- [JsonProperty("file", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("file")]
public string File { get; set; }
- [JsonProperty("file_prefix", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("file_prefix")]
public string FilePrefix { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ExportOperations/ExportS3CreateRequest.cs b/CloudConvert.API/Models/ExportOperations/ExportS3CreateRequest.cs
index 580c9d2..63194f1 100644
--- a/CloudConvert.API/Models/ExportOperations/ExportS3CreateRequest.cs
+++ b/CloudConvert.API/Models/ExportOperations/ExportS3CreateRequest.cs
@@ -1,90 +1,88 @@
using System.Collections.Generic;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
+using System.Text.Json.Serialization;
using CloudConvert.API.Models.Enums;
namespace CloudConvert.API.Models.ExportOperations
{
public class ExportS3CreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "export/s3";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "export/s3";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
///
/// The Amazon S3 bucket where to store the file(s).
///
- [JsonProperty("bucket")]
+ [JsonPropertyName("bucket")]
public string Bucket { get; set; }
///
/// Specify the Amazon S3 endpoint, e.g. us-west-2 or eu-west-1.
///
- [JsonProperty("region")]
+ [JsonPropertyName("region")]
public string Region { get; set; }
- [JsonProperty("endpoint", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("endpoint")]
public string Endpoint { get; set; }
///
/// S3 key for storing the file (the filename in the bucket, including path).
///
- [JsonProperty("key", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("key")]
public string Key { get; set; }
///
/// Alternatively to using key, you can specify a key prefix for exporting files.
///
- [JsonProperty("key_prefix", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("key_prefix")]
public string Key_Prefix { get; set; }
///
/// The Amazon S3 access key id.
///
- [JsonProperty("access_key_id")]
+ [JsonPropertyName("access_key_id")]
public string Access_Key_Id { get; set; }
///
/// The Amazon S3 secret access key.
///
- [JsonProperty("secret_access_key")]
+ [JsonPropertyName("secret_access_key")]
public string Secret_Access_Key { get; set; }
///
/// Auth using temporary credentials.
///
- [JsonProperty("session_token", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("session_token")]
public string Session_Token { get; set; }
///
/// S3 ACL for storing the files.
///
- [JsonProperty("acl", NullValueHandling = NullValueHandling.Ignore)]
- [JsonConverter(typeof(StringEnumConverter))]
+ [JsonPropertyName("acl")]
public ExportS3Acl? Acl { get; set; }
///
/// S3 CacheControl header to specify the lifetime of the file.
///
- [JsonProperty("cache_control", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("cache_control")]
public string Cache_Control { get; set; }
///
/// Object of additional S3 meta data.
///
- [JsonProperty("metadata", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("metadata")]
public Dictionary Metadata { get; set; }
///
/// Enable the Server-side encryption algorithm used when storing this object in S3.
///
- [JsonProperty("server_side_encryption", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("server_side_encryption")]
public string Server_Side_Encryption { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ExportOperations/ExportSFTPCreateRequest.cs b/CloudConvert.API/Models/ExportOperations/ExportSFTPCreateRequest.cs
index 3d60bbf..0378756 100644
--- a/CloudConvert.API/Models/ExportOperations/ExportSFTPCreateRequest.cs
+++ b/CloudConvert.API/Models/ExportOperations/ExportSFTPCreateRequest.cs
@@ -1,37 +1,38 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ExportOperations
{
public class ExportSFTPCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "export/sftp";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "export/sftp";
+
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
- [JsonProperty("host")]
+ [JsonPropertyName("host")]
public string Host { get; set; }
- [JsonProperty("port", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("port")]
public string Port { get; set; }
- [JsonProperty("username")]
+ [JsonPropertyName("username")]
public string Username { get; set; }
- [JsonProperty("password", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("password")]
public string Password { get; set; }
- [JsonProperty("private_key", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("private_key")]
public string Private_Key { get; set; }
- [JsonProperty("file", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("file")]
public string File { get; set; }
- [JsonProperty("path", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("path")]
public string Path { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ExportOperations/ExportUrlCreateRequest.cs b/CloudConvert.API/Models/ExportOperations/ExportUrlCreateRequest.cs
index 5338ad8..79a58d5 100644
--- a/CloudConvert.API/Models/ExportOperations/ExportUrlCreateRequest.cs
+++ b/CloudConvert.API/Models/ExportOperations/ExportUrlCreateRequest.cs
@@ -1,32 +1,32 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ExportOperations
{
public class ExportUrlCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "export/url";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "export/url";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
///
/// This option makes the export URLs return the Content-Disposition inline header, which tells browser to display the file instead of downloading it.
///
- [JsonProperty("inline", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("inline")]
public bool? Inline { get; set; }
- [JsonProperty("inline_additional", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("inline_additional")]
public bool? Inline_Additional { get; set; }
///
/// By default, multiple files will create multiple export URLs. When enabling this option, one export URL with a ZIP file will be created.
///
- [JsonProperty("archive_multiple_files", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("archive_multiple_files")]
public bool? Archive_Multiple_Files { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ImportOperations/ImportAzureBlobCreateRequest.cs b/CloudConvert.API/Models/ImportOperations/ImportAzureBlobCreateRequest.cs
index 2a17b96..9cbebe2 100644
--- a/CloudConvert.API/Models/ImportOperations/ImportAzureBlobCreateRequest.cs
+++ b/CloudConvert.API/Models/ImportOperations/ImportAzureBlobCreateRequest.cs
@@ -1,31 +1,31 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ImportOperations
{
public class ImportAzureBlobCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "import/azure/blob";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "import/azure/blob";
- [JsonProperty("storage_account")]
+ [JsonPropertyName("storage_account")]
public string Storage_Account { get; set; }
- [JsonProperty("storage_access_key", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("storage_access_key")]
public string Storage_Access_Key { get; set; }
- [JsonProperty("sas_token", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("sas_token")]
public string Sas_Token { get; set; }
- [JsonProperty("container")]
+ [JsonPropertyName("container")]
public string Container { get; set; }
- [JsonProperty("blob", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("blob")]
public string Blob { get; set; }
- [JsonProperty("blob_prefix", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("blob_prefix")]
public string Blob_Prefix { get; set; }
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ImportOperations/ImportGoogleCloudStorageCreateRequest.cs b/CloudConvert.API/Models/ImportOperations/ImportGoogleCloudStorageCreateRequest.cs
index dc0e629..d51867d 100644
--- a/CloudConvert.API/Models/ImportOperations/ImportGoogleCloudStorageCreateRequest.cs
+++ b/CloudConvert.API/Models/ImportOperations/ImportGoogleCloudStorageCreateRequest.cs
@@ -1,32 +1,31 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ImportOperations
{
public class ImportGoogleCloudStorageCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "import/google-cloud-storage";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "import/google-cloud-storage";
- [JsonProperty("project_id")]
+ [JsonPropertyName("project_id")]
public string Project_Id { get; set; }
- [JsonProperty("bucket")]
+ [JsonPropertyName("bucket")]
public string Bucket { get; set; }
- [JsonProperty("client_email")]
+ [JsonPropertyName("client_email")]
public string Client_Email { get; set; }
- [JsonProperty("private_key")]
+ [JsonPropertyName("private_key")]
public string Private_Key { get; set; }
- [JsonProperty("file", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("file")]
public string File { get; set; }
- [JsonProperty("file_prefix", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("file_prefix")]
public string File_Prefix { get; set; }
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
-
}
}
diff --git a/CloudConvert.API/Models/ImportOperations/ImportOpenStackCreateRequest.cs b/CloudConvert.API/Models/ImportOperations/ImportOpenStackCreateRequest.cs
index 3df5f43..224b250 100644
--- a/CloudConvert.API/Models/ImportOperations/ImportOpenStackCreateRequest.cs
+++ b/CloudConvert.API/Models/ImportOperations/ImportOpenStackCreateRequest.cs
@@ -1,34 +1,34 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ImportOperations
{
public class ImportOpenStackCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "import/openstack";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "import/openstack";
- [JsonProperty("auth_url")]
+ [JsonPropertyName("auth_url")]
public string Auth_Url { get; set; }
- [JsonProperty("username")]
+ [JsonPropertyName("username")]
public string Username { get; set; }
- [JsonProperty("password")]
+ [JsonPropertyName("password")]
public string Password { get; set; }
- [JsonProperty("region")]
+ [JsonPropertyName("region")]
public string Region { get; set; }
- [JsonProperty("container")]
+ [JsonPropertyName("container")]
public string Container { get; set; }
- [JsonProperty("file", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("file")]
public string File { get; set; }
- [JsonProperty("file_prefix", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("file_prefix")]
public string File_Prefix { get; set; }
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ImportOperations/ImportS3CreateRequest.cs b/CloudConvert.API/Models/ImportOperations/ImportS3CreateRequest.cs
index 9f85ab2..23b7d43 100644
--- a/CloudConvert.API/Models/ImportOperations/ImportS3CreateRequest.cs
+++ b/CloudConvert.API/Models/ImportOperations/ImportS3CreateRequest.cs
@@ -1,58 +1,58 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ImportOperations
{
public class ImportS3CreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "import/s3";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "import/s3";
///
/// The Amazon S3 bucket where to download the file.
///
- [JsonProperty("bucket")]
+ [JsonPropertyName("bucket")]
public string Bucket { get; set; }
///
/// Specify the Amazon S3 endpoint, e.g. us-west-2 or eu-west-1.
///
- [JsonProperty("region")]
+ [JsonPropertyName("region")]
public string Region { get; set; }
- [JsonProperty("endpoint", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("endpoint")]
public string Endpoint { get; set; }
///
/// S3 key of the input file (the filename in the bucket, including path).
///
- [JsonProperty("key", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("key")]
public string Key { get; set; }
///
/// Alternatively to using key, you can specify a key prefix for importing multiple files.
///
- [JsonProperty("key_prefix", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("key_prefix")]
public string Key_Prefix { get; set; }
///
/// The Amazon S3 access key id.
///
- [JsonProperty("access_key_id")]
+ [JsonPropertyName("access_key_id")]
public string Access_Key_Id { get; set; }
///
/// The Amazon S3 secret access key.
///
- [JsonProperty("secret_access_key")]
+ [JsonPropertyName("secret_access_key")]
public string Secret_Access_Key { get; set; }
///
/// Auth using temporary credentials.
///
- [JsonProperty("session_token", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("session_token")]
public string Session_Token { get; set; }
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ImportOperations/ImportSFTPCreateRequest.cs b/CloudConvert.API/Models/ImportOperations/ImportSFTPCreateRequest.cs
index a94a9d1..6facd7e 100644
--- a/CloudConvert.API/Models/ImportOperations/ImportSFTPCreateRequest.cs
+++ b/CloudConvert.API/Models/ImportOperations/ImportSFTPCreateRequest.cs
@@ -1,34 +1,34 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ImportOperations
{
public class ImportSFTPCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "import/sftp";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "import/sftp";
- [JsonProperty("host")]
+ [JsonPropertyName("host")]
public string Host { get; set; }
- [JsonProperty("port", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("port")]
public string Port { get; set; }
- [JsonProperty("username")]
+ [JsonPropertyName("username")]
public string Username { get; set; }
- [JsonProperty("password", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("password")]
public string Password { get; set; }
- [JsonProperty("private_key", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("private_key")]
public string Private_Key { get; set; }
- [JsonProperty("file", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("file")]
public string File { get; set; }
- [JsonProperty("path", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("path")]
public string Path { get; set; }
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ImportOperations/ImportUploadCreateRequest.cs b/CloudConvert.API/Models/ImportOperations/ImportUploadCreateRequest.cs
index f071703..d9dcfc9 100644
--- a/CloudConvert.API/Models/ImportOperations/ImportUploadCreateRequest.cs
+++ b/CloudConvert.API/Models/ImportOperations/ImportUploadCreateRequest.cs
@@ -1,16 +1,16 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ImportOperations
{
public class ImportUploadCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "import/upload";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "import/upload";
///
/// Redirect user to this URL after upload
///
- [JsonProperty("redirect", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("redirect")]
public string Redirect { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ImportOperations/ImportUrlCreateRequest.cs b/CloudConvert.API/Models/ImportOperations/ImportUrlCreateRequest.cs
index e317f60..abae899 100644
--- a/CloudConvert.API/Models/ImportOperations/ImportUrlCreateRequest.cs
+++ b/CloudConvert.API/Models/ImportOperations/ImportUrlCreateRequest.cs
@@ -1,24 +1,23 @@
using System.Collections.Generic;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.ImportOperations
{
public class ImportUrlCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "import/url";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "import/url";
- [JsonProperty("url")]
+ [JsonPropertyName("url")]
public string Url { get; set; }
///
/// The filename of the input file, including extension. If none provided we will try to detect the filename from the URL.
///
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
- [JsonProperty("headers", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("headers")]
public Dictionary Headers { get; set; }
-
}
}
diff --git a/CloudConvert.API/Models/JobModels/JobCreateRequest.cs b/CloudConvert.API/Models/JobModels/JobCreateRequest.cs
index 9b9ed09..1ae3276 100644
--- a/CloudConvert.API/Models/JobModels/JobCreateRequest.cs
+++ b/CloudConvert.API/Models/JobModels/JobCreateRequest.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.JobModels
{
@@ -8,17 +8,17 @@ public partial class JobCreateRequest
/// The example on the right consists of three tasks: import-my-file, convert-my-file and export-my-file.
/// You can name these tasks however you want, but only alphanumeric characters, - and _ are allowed in the task names.
///
- /// Each task has a operation, which is the endpoint for creating the task(for example: convert, import/s3 or export/s3).
+ /// Each task has an operation, which is the endpoint for creating the task (for example: convert, import/s3 or export/s3).
/// The other parameters are the same as for creating the task using their direct endpoint.
/// The input parameter allows it to directly reference the name of another task, created with the same job request.
///
- [JsonProperty("tasks")]
- public dynamic Tasks { get; set; }
+ [JsonPropertyName("tasks")]
+ public object Tasks { get; set; }
///
/// An arbitrary string to identify the job. Does not have any effect and can be used to associate the job with an ID in your application.
///
- [JsonProperty("tag")]
+ [JsonPropertyName("tag")]
public string Tag { get; set; }
}
}
diff --git a/CloudConvert.API/Models/JobModels/JobResponse.cs b/CloudConvert.API/Models/JobModels/JobResponse.cs
index b503e7b..471c9fc 100644
--- a/CloudConvert.API/Models/JobModels/JobResponse.cs
+++ b/CloudConvert.API/Models/JobModels/JobResponse.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
using CloudConvert.API.Models.TaskModels;
namespace CloudConvert.API.Models.JobModels
@@ -10,46 +10,46 @@ public partial class JobResponse
///
/// The ID of the job.
///
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
///
/// Your given tag of the job.
///
- [JsonProperty("tag")]
+ [JsonPropertyName("tag")]
public string Tag { get; set; }
///
/// The status of the job. Is one of processing, finished or error.
///
- [JsonProperty("status")]
+ [JsonPropertyName("status")]
public string Status { get; set; }
///
/// ISO8601 timestamp of the creation of the job.
///
- [JsonProperty("created_at")]
+ [JsonPropertyName("created_at")]
public DateTimeOffset? Created_At { get; set; }
///
/// ISO8601 timestamp when the job started processing.
///
- [JsonProperty("started_at")]
+ [JsonPropertyName("started_at")]
public DateTimeOffset? Started_At { get; set; }
///
/// ISO8601 timestamp when the job finished or failed.
///
- [JsonProperty("ended_at")]
+ [JsonPropertyName("ended_at")]
public DateTimeOffset? Ended_At { get; set; }
///
/// List of tasks that are part of the job. You can find details about the task model response in the documentation about the show tasks endpoint.
///
- [JsonProperty("tasks")]
+ [JsonPropertyName("tasks")]
public List Tasks { get; set; }
- [JsonProperty("links")]
+ [JsonPropertyName("links")]
public ResponseLinks Links { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ListResponse.cs b/CloudConvert.API/Models/ListResponse.cs
index bcdf1bb..25bcc04 100644
--- a/CloudConvert.API/Models/ListResponse.cs
+++ b/CloudConvert.API/Models/ListResponse.cs
@@ -1,17 +1,17 @@
using System.Collections.Generic;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models
{
public partial class ListResponse
{
- [JsonProperty("data")]
+ [JsonPropertyName("data")]
public List Data { get; set; }
- [JsonProperty("links")]
+ [JsonPropertyName("links")]
public ListResponseLinks Links { get; set; }
- [JsonProperty("meta")]
+ [JsonPropertyName("meta")]
public ListResponseMeta Meta { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ListResponseLinks.cs b/CloudConvert.API/Models/ListResponseLinks.cs
index 08bf886..c3a8010 100644
--- a/CloudConvert.API/Models/ListResponseLinks.cs
+++ b/CloudConvert.API/Models/ListResponseLinks.cs
@@ -1,20 +1,20 @@
using System;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models
{
public partial class ListResponseLinks
{
- [JsonProperty("first")]
+ [JsonPropertyName("first")]
public Uri First { get; set; }
- [JsonProperty("last")]
+ [JsonPropertyName("last")]
public Uri Last { get; set; }
- [JsonProperty("prev")]
+ [JsonPropertyName("prev")]
public Uri Prev { get; set; }
- [JsonProperty("next")]
+ [JsonPropertyName("next")]
public Uri Next { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ListResponseMeta.cs b/CloudConvert.API/Models/ListResponseMeta.cs
index d88aa11..6196cb5 100644
--- a/CloudConvert.API/Models/ListResponseMeta.cs
+++ b/CloudConvert.API/Models/ListResponseMeta.cs
@@ -1,23 +1,23 @@
using System;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models
{
public partial class ListResponseMeta
{
- [JsonProperty("current_page")]
+ [JsonPropertyName("current_page")]
public int? Current_Page { get; set; }
- [JsonProperty("from")]
+ [JsonPropertyName("from")]
public int? From { get; set; }
- [JsonProperty("path")]
+ [JsonPropertyName("path")]
public Uri Path { get; set; }
- [JsonProperty("per_page")]
+ [JsonPropertyName("per_page")]
public int? Per_Page { get; set; }
- [JsonProperty("to")]
+ [JsonPropertyName("to")]
public int? To { get; set; }
}
}
diff --git a/CloudConvert.API/Models/Response.cs b/CloudConvert.API/Models/Response.cs
index e6e76d4..ad19d29 100644
--- a/CloudConvert.API/Models/Response.cs
+++ b/CloudConvert.API/Models/Response.cs
@@ -1,10 +1,10 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models
{
public partial class Response
{
- [JsonProperty("data")]
+ [JsonPropertyName("data")]
public T Data { get; set; }
}
}
diff --git a/CloudConvert.API/Models/ResponseLinks.cs b/CloudConvert.API/Models/ResponseLinks.cs
index 7838413..e9a8fd6 100644
--- a/CloudConvert.API/Models/ResponseLinks.cs
+++ b/CloudConvert.API/Models/ResponseLinks.cs
@@ -1,11 +1,11 @@
using System;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models
{
public partial class ResponseLinks
{
- [JsonProperty("self")]
+ [JsonPropertyName("self")]
public Uri Self { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskModels/TaskResponse.cs b/CloudConvert.API/Models/TaskModels/TaskResponse.cs
index 3ea40ef..d21f0cf 100644
--- a/CloudConvert.API/Models/TaskModels/TaskResponse.cs
+++ b/CloudConvert.API/Models/TaskModels/TaskResponse.cs
@@ -1,7 +1,7 @@
using System;
-using Newtonsoft.Json;
-using CloudConvert.API.Models.Enums;
using System.Collections.Generic;
+using System.Text.Json.Serialization;
+using CloudConvert.API.Models.Enums;
namespace CloudConvert.API.Models.TaskModels
{
@@ -10,131 +10,131 @@ public partial class TaskResponse
///
/// The ID of the task.
///
- [JsonProperty("id")]
+ [JsonPropertyName("id")]
public string Id { get; set; }
///
- /// The Job ID the tasks belongs to.
+ /// The Job ID the task belongs to.
///
- [JsonProperty("job_id")]
+ [JsonPropertyName("job_id")]
public string Job_Id { get; set; }
- [JsonProperty("name")]
+ [JsonPropertyName("name")]
public string Name { get; set; }
///
/// Name of the operation, for example convert or import/s3.
///
- [JsonProperty("operation")]
+ [JsonPropertyName("operation")]
public string Operation { get; set; }
///
/// The status of the task. Is one of waiting, processing, finished or error.
///
- [JsonProperty("status")]
+ [JsonPropertyName("status")]
public TaskStatus Status { get; set; }
///
/// The amount of conversion minutes the task consumed. Available when the status is finished.
///
- [JsonProperty("credits")]
+ [JsonPropertyName("credits")]
public int? Credits { get; set; }
///
/// The status message. Contains the error message if the task status is error.
///
- [JsonProperty("message")]
+ [JsonPropertyName("message")]
public object Message { get; set; }
///
/// The error code if the task status is error.
///
- [JsonProperty("code")]
+ [JsonPropertyName("code")]
public string Code { get; set; }
- [JsonProperty("percent")]
+ [JsonPropertyName("percent")]
public int Percent { get; set; }
///
/// ISO8601 timestamp of the creation of the task.
///
- [JsonProperty("created_at")]
+ [JsonPropertyName("created_at")]
public DateTimeOffset? Created_At { get; set; }
///
/// ISO8601 timestamp when the task started processing.
///
- [JsonProperty("started_at")]
+ [JsonPropertyName("started_at")]
public DateTimeOffset? Started_At { get; set; }
///
/// ISO8601 timestamp when the task finished or failed.
///
- [JsonProperty("ended_at")]
+ [JsonPropertyName("ended_at")]
public DateTimeOffset? Ended_At { get; set; }
///
/// List of tasks that are dependencies for this task. Only available if the include parameter was set to depends_on_tasks.
///
- [JsonProperty("depends_on_tasks")]
+ [JsonPropertyName("depends_on_tasks")]
public object Depends_On_Tasks { get; set; }
- [JsonProperty("depends_on_task_ids")]
+ [JsonPropertyName("depends_on_task_ids")]
public List Depends_On_Task_Ids { get; set; }
///
/// ID of the original task, if this task is a retry.
///
- [JsonProperty("retry_of_task_id")]
+ [JsonPropertyName("retry_of_task_id")]
public string Retry_Of_Task_Id { get; set; }
- [JsonProperty("copy_of_task_id")]
+ [JsonPropertyName("copy_of_task_id")]
public object Copy_Of_Task_Id { get; set; }
- [JsonProperty("user_id")]
+ [JsonPropertyName("user_id")]
public int User_Id { get; set; }
- [JsonProperty("priority")]
+ [JsonPropertyName("priority")]
public long Priority { get; set; }
- [JsonProperty("host_name")]
+ [JsonPropertyName("host_name")]
public object Host_Name { get; set; }
- [JsonProperty("storage")]
+ [JsonPropertyName("storage")]
public string Storage { get; set; }
///
/// List of tasks that are retries of this task. Only available if the include parameter was set to retries.
///
- [JsonProperty("retries")]
+ [JsonPropertyName("retries")]
public string Retries { get; set; }
///
/// Name of the engine.
///
- [JsonProperty("engine")]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
///
/// Version of the engine.
///
- [JsonProperty("engine_version")]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
///
/// Your submitted payload for the tasks. Depends on the operation type.
///
- [JsonProperty("payload")]
+ [JsonPropertyName("payload")]
public object Payload { get; set; }
///
/// The result of the task. Depends on the operation type.
/// Finished tasks always do have a files key with the names of the result files of the task (See the example on the right).
///
- [JsonProperty("result")]
+ [JsonPropertyName("result")]
public TaskResult Result { get; set; }
-
- [JsonProperty("links")]
+
+ [JsonPropertyName("links")]
public ResponseLinks Links { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskModels/TaskResult.cs b/CloudConvert.API/Models/TaskModels/TaskResult.cs
index 51402aa..c0dd8bb 100644
--- a/CloudConvert.API/Models/TaskModels/TaskResult.cs
+++ b/CloudConvert.API/Models/TaskModels/TaskResult.cs
@@ -1,17 +1,17 @@
using System.Collections.Generic;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.TaskModels
{
public partial class TaskResult
{
- [JsonProperty("form")]
+ [JsonPropertyName("form")]
public UploadForm Form { get; set; }
- [JsonProperty("files")]
+ [JsonPropertyName("files")]
public List Files { get; set; }
- [JsonProperty("metadata")]
+ [JsonPropertyName("metadata")]
public Dictionary Metadata { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskModels/TaskResultFile.cs b/CloudConvert.API/Models/TaskModels/TaskResultFile.cs
index 520fe75..a288b1f 100644
--- a/CloudConvert.API/Models/TaskModels/TaskResultFile.cs
+++ b/CloudConvert.API/Models/TaskModels/TaskResultFile.cs
@@ -1,17 +1,17 @@
using System;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.TaskModels
{
public partial class TaskResultFile
{
- [JsonProperty("filename")]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
- [JsonProperty("size")]
+ [JsonPropertyName("size")]
public long Size { get; set; }
- [JsonProperty("url")]
+ [JsonPropertyName("url")]
public Uri Url { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskModels/UploadForm.cs b/CloudConvert.API/Models/TaskModels/UploadForm.cs
index b9ea952..2482278 100644
--- a/CloudConvert.API/Models/TaskModels/UploadForm.cs
+++ b/CloudConvert.API/Models/TaskModels/UploadForm.cs
@@ -1,14 +1,14 @@
using System;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.TaskModels
{
public partial class UploadForm
{
- [JsonProperty("url")]
+ [JsonPropertyName("url")]
public Uri Url { get; set; }
- [JsonProperty("parameters")]
+ [JsonPropertyName("parameters")]
public object Parameters { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskOperations/ArchiveCreateRequest.cs b/CloudConvert.API/Models/TaskOperations/ArchiveCreateRequest.cs
index a5ca018..033a4d8 100644
--- a/CloudConvert.API/Models/TaskOperations/ArchiveCreateRequest.cs
+++ b/CloudConvert.API/Models/TaskOperations/ArchiveCreateRequest.cs
@@ -1,38 +1,38 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.TaskOperations
{
public class ArchiveCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "archive";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "archive";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
- [JsonProperty("output_format")]
+ [JsonPropertyName("output_format")]
public string Output_Format { get; set; }
- [JsonProperty("engine", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
- [JsonProperty("engine_version", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
///
/// Choose a filename (including extension) for the output file.
///
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
///
/// Timeout in seconds after the task will be cancelled.
///
- [JsonProperty("timeout", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("timeout")]
public int? Timeout { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskOperations/CaptureCreateRequest.cs b/CloudConvert.API/Models/TaskOperations/CaptureCreateRequest.cs
index 8ed8eb4..4615ae5 100644
--- a/CloudConvert.API/Models/TaskOperations/CaptureCreateRequest.cs
+++ b/CloudConvert.API/Models/TaskOperations/CaptureCreateRequest.cs
@@ -1,98 +1,95 @@
using System.Collections.Generic;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
+using System.Text.Json.Serialization;
using CloudConvert.API.Models.Enums;
namespace CloudConvert.API.Models.TaskOperations
{
public class CaptureWebsiteCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "capture-website";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "capture-website";
///
/// URL of the website
///
- [JsonProperty("url")]
+ [JsonPropertyName("url")]
public string Url { get; set; }
- [JsonProperty("output_format")]
+ [JsonPropertyName("output_format")]
public string Output_Format { get; set; }
- [JsonProperty("engine", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
- [JsonProperty("engine_version", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
///
/// Choose a filename(including extension) for the output file.
///
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
- [JsonProperty("pages", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("pages")]
public string Pages { get; set; }
- [JsonProperty("zoom", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("zoom")]
public int? Zoom { get; set; }
- [JsonProperty("page_width", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("page_width")]
public int? Page_Width { get; set; }
-
- [JsonProperty("page_height", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("page_height")]
public int? Page_Height { get; set; }
- [JsonProperty("margin_top", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("margin_top")]
public int? Margin_Top { get; set; }
- [JsonProperty("margin_bottom", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("margin_bottom")]
public int? Margin_Bottom { get; set; }
- [JsonProperty("margin_left", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("margin_left")]
public int? Margin_Left { get; set; }
- [JsonProperty("margin_right", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("margin_right")]
public int? Margin_Right { get; set; }
- [JsonProperty("print_background", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("print_background")]
public bool? Print_Background { get; set; }
- [JsonProperty("display_header_footer", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("display_header_footer")]
public bool? Display_Header_Footer { get; set; }
- [JsonProperty("header_template", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("header_template")]
public string Header_Template { get; set; }
- [JsonProperty("footer_template", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("footer_template")]
public string Footer_Template { get; set; }
- [JsonProperty("wait_until", NullValueHandling = NullValueHandling.Ignore)]
- [JsonConverter(typeof(StringEnumConverter))]
+ [JsonPropertyName("wait_until")]
public CaptureWebsiteWaitUntil? Wait_Until { get; set; }
- [JsonProperty("wait_for_element", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("wait_for_element")]
public string Wait_For_Element { get; set; }
- [JsonProperty("wait_time", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("wait_time")]
public int? Wait_Time { get; set; }
- [JsonProperty("headers", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("headers")]
public Dictionary Headers { get; set; }
///
/// Timeout in seconds after the task will be cancelled.
///
- [JsonProperty("timeout", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("timeout")]
public int? Timeout { get; set; }
///
- /// Conversion and engine specific options. Depends on input_format and output_format.
+ /// Conversion and engine-specific options. Depends on input_format and output_format.
/// Select input and output format above to show additional conversion options.
///
[JsonExtensionData]
- [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("options")]
public Dictionary Options { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskOperations/CommandCreateRequest.cs b/CloudConvert.API/Models/TaskOperations/CommandCreateRequest.cs
index fbb1fec..a323a21 100644
--- a/CloudConvert.API/Models/TaskOperations/CommandCreateRequest.cs
+++ b/CloudConvert.API/Models/TaskOperations/CommandCreateRequest.cs
@@ -1,41 +1,41 @@
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.TaskOperations
{
public class CommandCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "command";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "command";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
- [JsonProperty("engine", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
- [JsonProperty("engine_version", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
///
/// Capture the console output of the command and return it in the results object.
///
- [JsonProperty("capture_output", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("capture_output")]
public bool? Capture_Output { get; set; }
- [JsonProperty("command", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("command")]
public string Command { get; set; }
- [JsonProperty("arguments", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("arguments")]
public string Arguments { get; set; }
///
/// Timeout in seconds after the task will be cancelled.
///
- [JsonProperty("timeout", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("timeout")]
public int? Timeout { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskOperations/ConvertCreateRequest.cs b/CloudConvert.API/Models/TaskOperations/ConvertCreateRequest.cs
index f4d4e34..ef09b03 100644
--- a/CloudConvert.API/Models/TaskOperations/ConvertCreateRequest.cs
+++ b/CloudConvert.API/Models/TaskOperations/ConvertCreateRequest.cs
@@ -1,44 +1,45 @@
using System.Collections.Generic;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.TaskOperations
{
public class ConvertCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "convert";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "convert";
+
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
///
/// If not set, the extension of the input file is used as input format
///
- [JsonProperty("input_format", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("input_format")]
public string Input_Format { get; set; }
- [JsonProperty("output_format")]
+ [JsonPropertyName("output_format")]
public string Output_Format { get; set; }
- [JsonProperty("engine", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
- [JsonProperty("engine_version", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
///
/// Choose a filename (including extension) for the output file.
///
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
///
/// Timeout in seconds after the task will be cancelled.
///
- [JsonProperty("timeout", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("timeout")]
public int? Timeout { get; set; }
///
@@ -46,8 +47,7 @@ public class ConvertCreateRequest
/// Select input and output format above to show additional conversion options.
///
[JsonExtensionData]
- [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("options")]
public Dictionary Options { get; set; }
-
}
}
diff --git a/CloudConvert.API/Models/TaskOperations/MergeCreateRequest.cs b/CloudConvert.API/Models/TaskOperations/MergeCreateRequest.cs
index 77278ba..f3e3aca 100644
--- a/CloudConvert.API/Models/TaskOperations/MergeCreateRequest.cs
+++ b/CloudConvert.API/Models/TaskOperations/MergeCreateRequest.cs
@@ -1,41 +1,39 @@
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
+using System.Text.Json.Serialization;
using CloudConvert.API.Models.Enums;
namespace CloudConvert.API.Models.TaskOperations
{
public class MergeCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "merge";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "merge";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
- [JsonProperty("output_format")]
- [JsonConverter(typeof(StringEnumConverter))]
+ [JsonPropertyName("output_format")]
public MergeOutputFormat Output_Format { get; set; }
- [JsonProperty("engine", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
- [JsonProperty("engine_version", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
///
/// Choose a filename (including extension) for the output file.
///
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
///
/// Timeout in seconds after the task will be cancelled.
///
- [JsonProperty("timeout", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("timeout")]
public int? Timeout { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskOperations/MetadataCreateRequest.cs b/CloudConvert.API/Models/TaskOperations/MetadataCreateRequest.cs
index 8772cb8..9eb795d 100644
--- a/CloudConvert.API/Models/TaskOperations/MetadataCreateRequest.cs
+++ b/CloudConvert.API/Models/TaskOperations/MetadataCreateRequest.cs
@@ -1,37 +1,40 @@
using System.Collections.Generic;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.TaskOperations
{
public class MetadataCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "metadata";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "metadata";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
///
/// If not set, the extension of the input file is used as input format
///
- [JsonProperty("input_format", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("input_format")]
public string Input_Format { get; set; }
- [JsonProperty("engine", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
- [JsonProperty("engine_version", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
- [JsonProperty("timeout", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("timeout")]
public int? Timeout { get; set; }
+ ///
+ /// Conversion and engine specific options. Depends on input_format and output_format.
+ ///
[JsonExtensionData]
- [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("options")]
public Dictionary Options { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskOperations/MetadataWriteCreateRequest.cs b/CloudConvert.API/Models/TaskOperations/MetadataWriteCreateRequest.cs
index f445755..e6ceb6f 100644
--- a/CloudConvert.API/Models/TaskOperations/MetadataWriteCreateRequest.cs
+++ b/CloudConvert.API/Models/TaskOperations/MetadataWriteCreateRequest.cs
@@ -1,40 +1,43 @@
using System.Collections.Generic;
-using Newtonsoft.Json;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.TaskOperations
{
public class MetadataWriteCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "metadata/write";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "metadata/write";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
///
/// If not set, the extension of the input file is used as input format
///
- [JsonProperty("input_format", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("input_format")]
public string Input_Format { get; set; }
- [JsonProperty("engine", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
- [JsonProperty("engine_version", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
- [JsonProperty("timeout", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("timeout")]
public int? Timeout { get; set; }
- [JsonProperty("metadata", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("metadata")]
public Dictionary Metadata { get; set; }
+ ///
+ /// Conversion and engine specific options. Depends on input_format and output_format.
+ ///
[JsonExtensionData]
- [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("options")]
public Dictionary Options { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskOperations/OptimizeCreateRequest.cs b/CloudConvert.API/Models/TaskOperations/OptimizeCreateRequest.cs
index 72d0cbd..5a98f1a 100644
--- a/CloudConvert.API/Models/TaskOperations/OptimizeCreateRequest.cs
+++ b/CloudConvert.API/Models/TaskOperations/OptimizeCreateRequest.cs
@@ -1,56 +1,56 @@
using System.Collections.Generic;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
+using System.Text.Json.Serialization;
using CloudConvert.API.Models.Enums;
namespace CloudConvert.API.Models.TaskOperations
{
public class OptimizeCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "optimize";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "optimize";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
///
/// If not set, the extension of the input file is used as input format
///
- [JsonConverter(typeof(StringEnumConverter))]
- [JsonProperty("input_format", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("input_format")]
public OptimizeInputFormat? Input_Format { get; set; }
- [JsonProperty("engine", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
- [JsonProperty("engine_version", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
///
/// Choose a filename (including extension) for the output file.
///
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
- [JsonProperty("quality", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("quality")]
public int? Quality { get; set; }
- [JsonConverter(typeof(StringEnumConverter))]
- [JsonProperty("profile", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("profile")]
public OptimizeProfile? Profile { get; set; }
///
/// Timeout in seconds after the task will be cancelled.
///
- [JsonProperty("timeout", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("timeout")]
public int? Timeout { get; set; }
+ ///
+ /// Conversion and engine specific options. Depends on input_format and output_format.
+ ///
[JsonExtensionData]
- [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("options")]
public Dictionary Options { get; set; }
}
}
diff --git a/CloudConvert.API/Models/TaskOperations/ThumbnailCreateRequest.cs b/CloudConvert.API/Models/TaskOperations/ThumbnailCreateRequest.cs
index 96f399c..fc19a3b 100644
--- a/CloudConvert.API/Models/TaskOperations/ThumbnailCreateRequest.cs
+++ b/CloudConvert.API/Models/TaskOperations/ThumbnailCreateRequest.cs
@@ -1,73 +1,70 @@
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
using System.Collections.Generic;
+using System.Text.Json.Serialization;
using CloudConvert.API.Models.Enums;
namespace CloudConvert.API.Models.TaskOperations
{
public class ThumbnailCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "thumbnail";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "thumbnail";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
///
/// If not set, the extension of the input file is used as input format
///
- [JsonProperty("input_format", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("input_format")]
public string Input_Format { get; set; }
- [JsonProperty("output_format")]
- [JsonConverter(typeof(StringEnumConverter))]
+ [JsonPropertyName("output_format")]
public ThumbnailOutputFormat Output_Format { get; set; }
- [JsonProperty("engine", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
- [JsonProperty("engine_version", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
///
/// Choose a filename (including extension) for the output file.
///
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
///
/// Timeout in seconds after the task will be cancelled.
///
- [JsonProperty("timeout", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("timeout")]
public int? Timeout { get; set; }
///
/// Sets the mode of sizing the thumbnail. "Max" resizes the thumbnail to fit within the width and height, but will not increase the size of the image if it is smaller than width or height. "Crop" resizes the thumbnail to fill the width and height dimensions and crops any excess image data. "Scale" enforces the thumbnail width and height by scaling. Defaults to max.
///
- [JsonProperty("fit", NullValueHandling = NullValueHandling.Ignore)]
- [JsonConverter(typeof(StringEnumConverter))]
+ [JsonPropertyName("fit")]
public ThumbnailFit? Fit { get; set; }
///
/// Set thumbnail width in pixels.
///
- [JsonProperty("width", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("width")]
public int? Width { get; set; }
///
/// Set thumbnail height in pixels.
///
- [JsonProperty("height", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("height")]
public int? Height { get; set; }
///
/// Number of thumbnails to create. Defaults to 1.
///
- [JsonProperty("count", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("count")]
public int? Count { get; set; }
///
@@ -75,8 +72,7 @@ public class ThumbnailCreateRequest
/// Select input and output format above to show additional conversion options.
///
[JsonExtensionData]
- [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("options")]
public Dictionary Options { get; set; }
-
}
}
diff --git a/CloudConvert.API/Models/TaskOperations/WatermarkCreateRequest.cs b/CloudConvert.API/Models/TaskOperations/WatermarkCreateRequest.cs
index e2df967..8025c82 100644
--- a/CloudConvert.API/Models/TaskOperations/WatermarkCreateRequest.cs
+++ b/CloudConvert.API/Models/TaskOperations/WatermarkCreateRequest.cs
@@ -1,43 +1,42 @@
-using Newtonsoft.Json;
using System.Collections.Generic;
+using System.Text.Json.Serialization;
namespace CloudConvert.API.Models.TaskOperations
{
public class WatermarkCreateRequest
{
- [JsonProperty("operation")]
- public static string Operation = "watermark";
+ [JsonPropertyName("operation")]
+ public string Operation { get; } = "watermark";
///
/// The input task name(s) for this task.
/// input: string | string[];
///
- [JsonProperty("input")]
- public dynamic Input { get; set; }
+ [JsonPropertyName("input")]
+ public object Input { get; set; }
///
/// If not set, the extension of the input file is used as input format
///
- [JsonProperty("input_format", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("input_format")]
public string Input_Format { get; set; }
-
- [JsonProperty("engine", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine")]
public string Engine { get; set; }
- [JsonProperty("engine_version", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("engine_version")]
public string Engine_Version { get; set; }
///
/// Choose a filename (including extension) for the output file.
///
- [JsonProperty("filename", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("filename")]
public string Filename { get; set; }
///
/// Timeout in seconds after the task will be cancelled.
///
- [JsonProperty("timeout", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("timeout")]
public int? Timeout { get; set; }
///
@@ -45,8 +44,7 @@ public class WatermarkCreateRequest
/// Select input and output format above to show additional conversion options.
///
[JsonExtensionData]
- [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)]
+ [JsonPropertyName("options")]
public Dictionary Options { get; set; }
-
}
}
diff --git a/CloudConvert.API/RestHelper.cs b/CloudConvert.API/RestHelper.cs
index 36108e3..8379f9e 100644
--- a/CloudConvert.API/RestHelper.cs
+++ b/CloudConvert.API/RestHelper.cs
@@ -1,5 +1,5 @@
-using Newtonsoft.Json;
using System.Net.Http;
+using System.Text.Json;
using System.Threading.Tasks;
namespace CloudConvert.API
@@ -22,16 +22,14 @@ internal RestHelper(HttpClient httpClient)
public async Task RequestAsync(HttpRequestMessage request)
{
var response = await _httpClient.SendAsync(request);
-
var responseRaw = await response.Content.ReadAsStringAsync();
- return JsonConvert.DeserializeObject(responseRaw);
+ return JsonSerializer.Deserialize(responseRaw, DefaultJsonSerializerOptions.SerializerOptions);
}
public async Task RequestAsync(HttpRequestMessage request)
{
var response = await _httpClient.SendAsync(request);
-
return await response.Content.ReadAsStringAsync();
}
}
diff --git a/CloudConvert.Test/IntegrationTests.cs b/CloudConvert.Test/IntegrationTests.cs
index 82341a9..caed31a 100644
--- a/CloudConvert.Test/IntegrationTests.cs
+++ b/CloudConvert.Test/IntegrationTests.cs
@@ -10,6 +10,8 @@
using System.Net.Http;
using CloudConvert.API.Models.TaskOperations;
using System.Collections.Generic;
+using System.Dynamic;
+using System.Text.Json;
namespace CloudConvert.Test
{
@@ -85,7 +87,7 @@ public async Task CreateJob(string streamingMethod)
await File.WriteAllBytesAsync(fileExport.Filename, fileBytes);
}
-
+
[Test]
public async Task CreateJobWithOptions()
{
@@ -96,15 +98,15 @@ public async Task CreateJobWithOptions()
import_it = new ImportUploadCreateRequest(),
convert_it = new ConvertCreateRequest
{
- Input = "import_it",
+ Input = "import_it",
Input_Format = "pdf",
Output_Format = "jpg",
Options = new Dictionary {
- { "width", 800 },
- { "height", 600 },
- { "fit", "max" }
- }
+ { "width", 800 },
+ { "height", 600 },
+ { "fit", "max" }
}
+ }
},
Tag = "integration-test-convert-with-options"
});
@@ -120,11 +122,11 @@ public async Task CreateJobWithOptions()
// get created convert task
var convertTask = await _cloudConvertAPI.GetTaskAsync(job.Data.Tasks.FirstOrDefault(t => t.Name == "convert_it").Id, "payload");
- var payload = ((Newtonsoft.Json.Linq.JObject)convertTask.Data.Payload).ToObject>();
+ dynamic payload = JsonSerializer.Deserialize(convertTask.Data.Payload.ToString());
Assert.IsNotNull(payload);
- Assert.AreEqual(800, payload["width"]);
- Assert.AreEqual(600, payload["height"]);
- Assert.AreEqual("max", payload["fit"]);
+ Assert.AreEqual(800, ((JsonElement)payload.width).GetInt32());
+ Assert.AreEqual(600, ((JsonElement)payload.height).GetInt32());
+ Assert.AreEqual("max", ((JsonElement)payload.fit).GetString());
}
@@ -136,7 +138,7 @@ public async Task CreateTask(string streamingMethod)
var reqImport = new ImportUploadCreateRequest();
- var importTask = await _cloudConvertAPI.CreateTaskAsync(ImportUploadCreateRequest.Operation, reqImport);
+ var importTask = await _cloudConvertAPI.CreateTaskAsync(reqImport.Operation, reqImport);
var path = AppDomain.CurrentDomain.BaseDirectory + @"TestFiles/input.pdf";
string fileName = "input.pdf";
@@ -169,7 +171,7 @@ public async Task CreateTask(string streamingMethod)
Input = importTask.Data.Id
};
- var exportTask = await _cloudConvertAPI.CreateTaskAsync(ExportUrlCreateRequest.Operation, reqExport);
+ var exportTask = await _cloudConvertAPI.CreateTaskAsync(reqExport.Operation, reqExport);
Assert.IsNotNull(exportTask);
diff --git a/CloudConvert.Test/TestJobs.cs b/CloudConvert.Test/TestJobs.cs
index 895a430..835b729 100644
--- a/CloudConvert.Test/TestJobs.cs
+++ b/CloudConvert.Test/TestJobs.cs
@@ -1,11 +1,12 @@
using System;
using System.IO;
+using System.Text.Json;
+using System.Text.Json.Serialization;
using System.Threading.Tasks;
using CloudConvert.API;
using CloudConvert.API.Models;
using CloudConvert.API.Models.JobModels;
using Moq;
-using Newtonsoft.Json;
using NUnit.Framework;
namespace CloudConvert.Test
@@ -24,7 +25,7 @@ public async Task GetAllJobs()
var path = @"Responses/jobs.json";
string json = File.ReadAllText(path);
_cloudConvertAPI.Setup(cc => cc.GetAllJobsAsync(filter))
- .ReturnsAsync(JsonConvert.DeserializeObject>(json));
+ .ReturnsAsync(JsonSerializer.Deserialize>(json, DefaultJsonSerializerOptions.SerializerOptions));
var jobs = await _cloudConvertAPI.Object.GetAllJobsAsync(filter);
@@ -35,7 +36,7 @@ public async Task GetAllJobs()
{
if (ex.InnerException != null)
{
- var error = JsonConvert.DeserializeObject(ex.InnerException.Message);
+ var error = JsonSerializer.Deserialize(ex.InnerException.Message, DefaultJsonSerializerOptions.SerializerOptions);
}
else
{
@@ -56,7 +57,7 @@ public async Task CreateJob()
var path = AppDomain.CurrentDomain.BaseDirectory + @"Responses/job_created.json";
string json = File.ReadAllText(path);
_cloudConvertAPI.Setup(cc => cc.CreateJobAsync(req))
- .ReturnsAsync(JsonConvert.DeserializeObject>(json));
+ .ReturnsAsync(JsonSerializer.Deserialize>(json, DefaultJsonSerializerOptions.SerializerOptions));
var job = await _cloudConvertAPI.Object.CreateJobAsync(req);
@@ -73,7 +74,7 @@ public async Task GetJob()
var path = AppDomain.CurrentDomain.BaseDirectory + @"Responses/job.json";
string json = File.ReadAllText(path);
_cloudConvertAPI.Setup(cc => cc.GetJobAsync(id))
- .ReturnsAsync(JsonConvert.DeserializeObject>(json));
+ .ReturnsAsync(JsonSerializer.Deserialize>(json, DefaultJsonSerializerOptions.SerializerOptions));
var job = await _cloudConvertAPI.Object.GetJobAsync(id);
@@ -90,7 +91,7 @@ public async Task WaitJob()
var path = AppDomain.CurrentDomain.BaseDirectory + @"Responses/job_finished.json";
string json = File.ReadAllText(path);
_cloudConvertAPI.Setup(cc => cc.WaitJobAsync(id))
- .ReturnsAsync(JsonConvert.DeserializeObject>(json));
+ .ReturnsAsync(JsonSerializer.Deserialize>(json, DefaultJsonSerializerOptions.SerializerOptions));
var job = await _cloudConvertAPI.Object.WaitJobAsync(id);
@@ -108,6 +109,5 @@ public async Task DeleteJob()
await _cloudConvertAPI.Object.DeleteJobAsync(id);
}
-
}
}
diff --git a/CloudConvert.Test/TestSignedUrl.cs b/CloudConvert.Test/TestSignedUrl.cs
index 825a468..7c0353b 100644
--- a/CloudConvert.Test/TestSignedUrl.cs
+++ b/CloudConvert.Test/TestSignedUrl.cs
@@ -41,16 +41,13 @@ public void Sign()
};
-
string signedUrl = _cloudConvertAPI.CreateSignedUrl(baseUrl, signingSecret, job, cacheKey);
StringAssert.StartsWith(baseUrl, signedUrl);
StringAssert.Contains("?job=", signedUrl);
StringAssert.Contains("&cache_key=mykey", signedUrl);
- StringAssert.Contains("&s=05521324eb16876aac906f2edc42a7ebfe6e71743e6cb965c4b3bf224c2b581f", signedUrl);
-
-
+ StringAssert.Contains("&s=81213540c2ccdf3330a0cf237642f14b381f57cf5bbffe293eb118468fde700b", signedUrl);
}
}
}
diff --git a/CloudConvert.Test/TestTasks.cs b/CloudConvert.Test/TestTasks.cs
index f8e1a8e..c978851 100644
--- a/CloudConvert.Test/TestTasks.cs
+++ b/CloudConvert.Test/TestTasks.cs
@@ -10,7 +10,7 @@
using CloudConvert.Test.Extensions;
using Moq;
using Moq.Protected;
-using Newtonsoft.Json;
+using System.Text.Json;
using NUnit.Framework;
namespace CloudConvert.Test
@@ -29,7 +29,7 @@ public async Task GetAllTasks()
var cloudConvertApi = new Mock();
cloudConvertApi.Setup(cc => cc.GetAllTasksAsync(filter))
- .ReturnsAsync(JsonConvert.DeserializeObject>(json));
+ .ReturnsAsync(JsonSerializer.Deserialize>(json, DefaultJsonSerializerOptions.SerializerOptions));
var tasks = await cloudConvertApi.Object.GetAllTasksAsync(filter);
@@ -40,7 +40,7 @@ public async Task GetAllTasks()
{
if (ex.InnerException != null)
{
- var error = JsonConvert.DeserializeObject(ex.InnerException.Message);
+ var error = JsonSerializer.Deserialize(ex.InnerException.Message, DefaultJsonSerializerOptions.SerializerOptions);
}
else
{
@@ -68,10 +68,10 @@ public async Task CreateTask()
string json = File.ReadAllText(path);
var cloudConvertApi = new Mock();
- cloudConvertApi.Setup(cc => cc.CreateTaskAsync(ConvertCreateRequest.Operation, req))
- .ReturnsAsync(JsonConvert.DeserializeObject>(json));
+ cloudConvertApi.Setup(cc => cc.CreateTaskAsync(req.Operation, req))
+ .ReturnsAsync(JsonSerializer.Deserialize>(json, DefaultJsonSerializerOptions.SerializerOptions));
- var task = await cloudConvertApi.Object.CreateTaskAsync(ConvertCreateRequest.Operation, req);
+ var task = await cloudConvertApi.Object.CreateTaskAsync(req.Operation, req);
Assert.IsNotNull(task);
Assert.IsTrue(task.Data.Status == API.Models.Enums.TaskStatus.waiting);
@@ -87,7 +87,7 @@ public async Task GetTask()
var _cloudConvertAPI = new Mock();
_cloudConvertAPI.Setup(cc => cc.GetTaskAsync(id, null))
- .ReturnsAsync(JsonConvert.DeserializeObject>(json));
+ .ReturnsAsync(JsonSerializer.Deserialize>(json, DefaultJsonSerializerOptions.SerializerOptions));
var task = await _cloudConvertAPI.Object.GetTaskAsync("9de1a620-952c-4482-9d44-681ae28d72a1");
@@ -105,7 +105,7 @@ public async Task WaitTask()
var cloudConvertApi = new Mock();
cloudConvertApi.Setup(cc => cc.WaitTaskAsync(id))
- .ReturnsAsync(JsonConvert.DeserializeObject>(json));
+ .ReturnsAsync(JsonSerializer.Deserialize>(json, DefaultJsonSerializerOptions.SerializerOptions));
var task = await cloudConvertApi.Object.WaitTaskAsync(id);
@@ -133,10 +133,10 @@ public async Task Upload()
var path = AppDomain.CurrentDomain.BaseDirectory + @"Responses/upload_task_created.json";
string json = File.ReadAllText(path);
- cloudConvertApi.Setup(cc => cc.CreateTaskAsync(ImportUploadCreateRequest.Operation, req))
- .ReturnsAsync(JsonConvert.DeserializeObject>(json));
+ cloudConvertApi.Setup(cc => cc.CreateTaskAsync(req.Operation, req))
+ .ReturnsAsync(JsonSerializer.Deserialize>(json, DefaultJsonSerializerOptions.SerializerOptions));
- var task = await cloudConvertApi.Object.CreateTaskAsync(ImportUploadCreateRequest.Operation, req);
+ var task = await cloudConvertApi.Object.CreateTaskAsync(req.Operation, req);
Assert.IsNotNull(task);
@@ -161,7 +161,7 @@ public async Task UploadStream()
var req = new ImportUploadCreateRequest();
var cloudConvertApi = new CloudConvertAPI(restHelper, "API_KEY");
- var task = await cloudConvertApi.CreateTaskAsync(ImportUploadCreateRequest.Operation, req);
+ var task = await cloudConvertApi.CreateTaskAsync(req.Operation, req);
Assert.IsNotNull(task);
httpMessageHandlerMock.VerifyRequest("/import/upload", Times.Once());