From b808120dba0fbb65cf5a1241c605dbf344ab0752 Mon Sep 17 00:00:00 2001 From: cloudpdf-sdk-bot Date: Thu, 20 Aug 2026 21:06:48 +0000 Subject: [PATCH] chore: generate CloudPDF .NET SDK 3.0.0-next.6 --- .fern/metadata.json | 6 +- cloudpdf-generation.json | 8 +- reference.md | 64 ++++ .../MockServer/Documents/ImportFromTest.cs | 149 +++++++++ src/CloudPDF/CloudPDF.csproj | 2 +- src/CloudPDF/Core/Public/Version.cs | 2 +- src/CloudPDF/Documents/DocumentsClient.cs | 161 ++++++++++ src/CloudPDF/Documents/IDocumentsClient.cs | 9 + .../Requests/DocumentsImportFromRequest.cs | 38 +++ .../DocumentsImportFromRequestDedupMode.cs | 123 ++++++++ .../DocumentsImportFromRequestExpected.cs | 31 ++ .../Types/DocumentsImportFromRequestMode.cs | 116 +++++++ .../Types/DocumentsImportFromRequestSource.cs | 292 ++++++++++++++++++ ...umentsImportFromRequestSourceConnection.cs | 34 ++ .../DocumentsImportFromRequestSourceUrl.cs | 28 ++ src/CloudPDF/Exceptions/BadGatewayError.cs | 16 + .../Types/DocumentsImportFrom200Response.cs | 31 ++ .../DocumentsImportFrom200ResponseDocument.cs | 64 ++++ ...mentsImportFrom200ResponseDocumentState.cs | 136 ++++++++ ...rtFrom200ResponseDocumentThumbnailState.cs | 142 +++++++++ .../DocumentsImportFrom200ResponseTag.cs | 122 ++++++++ .../Types/DocumentsImportFrom202Response.cs | 31 ++ .../DocumentsImportFrom202ResponseDocument.cs | 64 ++++ ...mentsImportFrom202ResponseDocumentState.cs | 136 ++++++++ ...rtFrom202ResponseDocumentThumbnailState.cs | 142 +++++++++ .../DocumentsImportFrom202ResponseTag.cs | 122 ++++++++ .../Types/DocumentsImportFrom400Response.cs | 28 ++ .../DocumentsImportFrom400ResponseError.cs | 31 ++ .../Types/DocumentsImportFrom403Response.cs | 28 ++ .../DocumentsImportFrom403ResponseError.cs | 31 ++ .../Types/DocumentsImportFrom502Response.cs | 28 ++ .../DocumentsImportFrom502ResponseError.cs | 31 ++ 32 files changed, 2237 insertions(+), 9 deletions(-) create mode 100644 src/CloudPDF.Test/Unit/MockServer/Documents/ImportFromTest.cs create mode 100644 src/CloudPDF/Documents/Requests/DocumentsImportFromRequest.cs create mode 100644 src/CloudPDF/Documents/Types/DocumentsImportFromRequestDedupMode.cs create mode 100644 src/CloudPDF/Documents/Types/DocumentsImportFromRequestExpected.cs create mode 100644 src/CloudPDF/Documents/Types/DocumentsImportFromRequestMode.cs create mode 100644 src/CloudPDF/Documents/Types/DocumentsImportFromRequestSource.cs create mode 100644 src/CloudPDF/Documents/Types/DocumentsImportFromRequestSourceConnection.cs create mode 100644 src/CloudPDF/Documents/Types/DocumentsImportFromRequestSourceUrl.cs create mode 100644 src/CloudPDF/Exceptions/BadGatewayError.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom200Response.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom200ResponseDocument.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom200ResponseDocumentState.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom200ResponseDocumentThumbnailState.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom200ResponseTag.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom202Response.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom202ResponseDocument.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom202ResponseDocumentState.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom202ResponseDocumentThumbnailState.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom202ResponseTag.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom400Response.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom400ResponseError.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom403Response.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom403ResponseError.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom502Response.cs create mode 100644 src/CloudPDF/Types/DocumentsImportFrom502ResponseError.cs diff --git a/.fern/metadata.json b/.fern/metadata.json index e155c09..4701f11 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -10,10 +10,10 @@ "base-exception-class-name": "CloudPDFException", "base-api-exception-class-name": "CloudPDFApiException" }, - "originGitCommit": "81e6a2097d2997ef713a3013668e5eae0e748575", + "originGitCommit": "32635f40577b214f6a6b3189a2271425c3a574fd", "originGitCommitIsDirty": false, "invokedBy": "ci", - "requestedVersion": "3.0.0-next.5", + "requestedVersion": "3.0.0-next.6", "ciProvider": "github", - "sdkVersion": "3.0.0-next.5" + "sdkVersion": "3.0.0-next.6" } \ No newline at end of file diff --git a/cloudpdf-generation.json b/cloudpdf-generation.json index 160158a..3a729ba 100644 --- a/cloudpdf-generation.json +++ b/cloudpdf-generation.json @@ -1,12 +1,12 @@ { "language": "csharp", - "canonicalVersion": "3.0.0-next.5", - "sdkVersion": "3.0.0-next.5", + "canonicalVersion": "3.0.0-next.6", + "sdkVersion": "3.0.0-next.6", "source": { "repository": "embedpdf/embed-pdf-viewer", "openapi": "cloudpdf/contract/openapi.json", - "openapiSha256": "e86b3f1766a77c28cb782a6513b5a86998668cd4e688e5b5ac27342e58637cd7", - "gitCommit": "81e6a2097d2997ef713a3013668e5eae0e748575", + "openapiSha256": "b3e236a932673e27e05825352e1bc3675369d7505040bf7d7760e542aae8d38d", + "gitCommit": "32635f40577b214f6a6b3189a2271425c3a574fd", "gitCommitIsDirty": false }, "fern": { diff --git a/reference.md b/reference.md index 81781a4..45b49fa 100644 --- a/reference.md +++ b/reference.md @@ -1161,6 +1161,70 @@ await client.Documents.UploadProxyAsync( + + + + +
client.Documents.ImportFromAsync(DocumentsImportFromRequest { ... }) -> WithRawResponseTask<DocumentsImportFrom200Response> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Default mode is synchronous and bounded: the response returns only after the transfer verified and committed (or failed). mode=async (connection sources only) answers 202 immediately and an in-process worker performs the transfer with leased, fenced retries; poll the document until ready/failed. The deployment import policy gates scheme, network range, and size; sources must declare a length. CloudPDF copies and owns the bytes — the source is never referenced in place. A 502 marks a retryable upstream failure: retry with the same idempotencyKey to resume the same document. URL sources are capabilities and never echoed back. Connection sources name operator-registered storage (bucket/prefix scope, allowed credential classes, and tenant bindings are deployment configuration); `revision` is provider-interpreted (S3 VersionId, GCS generation, Azure version id). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Documents.ImportFromAsync( + new DocumentsImportFromRequest + { + TenantId = "tenantId", + Source = new DocumentsImportFromRequestSource( + new DocumentsImportFromRequestSource.Url( + new DocumentsImportFromRequestSourceUrl { Url = "url" } + ) + ), + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `DocumentsImportFromRequest` + +
+
+
+
+ +
diff --git a/src/CloudPDF.Test/Unit/MockServer/Documents/ImportFromTest.cs b/src/CloudPDF.Test/Unit/MockServer/Documents/ImportFromTest.cs new file mode 100644 index 0000000..998897f --- /dev/null +++ b/src/CloudPDF.Test/Unit/MockServer/Documents/ImportFromTest.cs @@ -0,0 +1,149 @@ +using CloudPDF; +using CloudPDF.Test.Unit.MockServer; +using CloudPDF.Test.Utils; +using NUnit.Framework; + +namespace CloudPDF.Test.Unit.MockServer.Documents; + +[TestFixture] +[Parallelizable(ParallelScope.Self)] +public class ImportFromTest : BaseMockServerTest +{ + [NUnit.Framework.Test] + public async Task MockServerTest_1() + { + const string requestJson = """ + { + "source": { + "kind": "url", + "url": "url" + } + } + """; + + const string mockResponse = """ + { + "tag": "imported", + "document": { + "id": "id", + "tenantId": "tenantId", + "state": "pending", + "baseSha": "baseSha", + "storageSizeBytes": 1.1, + "metadata": { + "metadata": { + "key": "value" + } + }, + "idempotencyKey": "idempotencyKey", + "failureReason": "failureReason", + "thumbnailState": "pending", + "thumbnailUrl": "thumbnailUrl", + "createdAt": 1.1, + "updatedAt": 1.1, + "createdBy": "createdBy" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v1/tenants/tenantId/documents/import") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Documents.ImportFromAsync( + new DocumentsImportFromRequest + { + TenantId = "tenantId", + Source = new DocumentsImportFromRequestSource( + new DocumentsImportFromRequestSource.Url( + new DocumentsImportFromRequestSourceUrl { Url = "url" } + ) + ), + Expected = null, + Metadata = null, + IdempotencyKey = null, + DedupMode = null, + DocId = null, + Mode = null, + } + ); + JsonAssert.AreEqual(response, mockResponse); + } + + [NUnit.Framework.Test] + public async Task MockServerTest_2() + { + const string requestJson = """ + { + "source": { + "kind": "url", + "url": "url" + } + } + """; + + const string mockResponse = """ + { + "tag": "imported", + "document": { + "id": "id", + "tenantId": "tenantId", + "state": "pending", + "baseSha": "baseSha", + "storageSizeBytes": 1.1, + "metadata": { + "key": "value" + }, + "idempotencyKey": "idempotencyKey", + "failureReason": "failureReason", + "thumbnailState": "pending", + "thumbnailUrl": "thumbnailUrl", + "createdAt": 1.1, + "updatedAt": 1.1, + "createdBy": "createdBy" + } + } + """; + + Server + .Given( + WireMock + .RequestBuilders.Request.Create() + .WithPath("/v1/tenants/tenantId/documents/import") + .WithHeader("Content-Type", "application/json") + .UsingPost() + .WithBodyAsJson(requestJson) + ) + .RespondWith( + WireMock + .ResponseBuilders.Response.Create() + .WithStatusCode(200) + .WithBody(mockResponse) + ); + + var response = await Client.Documents.ImportFromAsync( + new DocumentsImportFromRequest + { + TenantId = "tenantId", + Source = new DocumentsImportFromRequestSource( + new DocumentsImportFromRequestSource.Url( + new DocumentsImportFromRequestSourceUrl { Url = "url" } + ) + ), + } + ); + JsonAssert.AreEqual(response, mockResponse); + } +} diff --git a/src/CloudPDF/CloudPDF.csproj b/src/CloudPDF/CloudPDF.csproj index 5ee7977..1631bb2 100644 --- a/src/CloudPDF/CloudPDF.csproj +++ b/src/CloudPDF/CloudPDF.csproj @@ -11,7 +11,7 @@ enable 12 enable - 3.0.0-next.5 + 3.0.0-next.6 3.0.0.0 3.0.0.0 README.md diff --git a/src/CloudPDF/Core/Public/Version.cs b/src/CloudPDF/Core/Public/Version.cs index 134e286..71c600a 100644 --- a/src/CloudPDF/Core/Public/Version.cs +++ b/src/CloudPDF/Core/Public/Version.cs @@ -3,5 +3,5 @@ namespace CloudPDF; [Serializable] internal class Version { - public const string Current = "3.0.0-next.5"; + public const string Current = "3.0.0-next.6"; } diff --git a/src/CloudPDF/Documents/DocumentsClient.cs b/src/CloudPDF/Documents/DocumentsClient.cs index f65ec8f..08cc119 100644 --- a/src/CloudPDF/Documents/DocumentsClient.cs +++ b/src/CloudPDF/Documents/DocumentsClient.cs @@ -758,6 +758,140 @@ private async Task> UploadProxy } } + private async Task> ImportFromAsyncCore( + DocumentsImportFromRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new CloudPDF.Core.QueryStringBuilder.Builder(capacity: 0) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new CloudPDF.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Post, + Path = string.Format( + "v1/tenants/{0}/documents/import", + ValueConvert.ToPathParameterString(request.TenantId) + ), + Body = request, + QueryString = _queryString, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new CloudPDFApiException( + "Failed to deserialize response", + response.StatusCode, + responseBody, + e, + rawResponse: new CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError( + JsonUtils.Deserialize(responseBody), + rawResponse: new CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 403: + throw new ForbiddenError( + JsonUtils.Deserialize(responseBody), + rawResponse: new CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + case 502: + throw new BadGatewayError( + JsonUtils.Deserialize(responseBody), + rawResponse: new CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = + response.Raw.RequestMessage?.RequestUri + ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new CloudPDFApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody, + rawResponse: new CloudPDF.RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + } + ); + } + } + private async Task> InitAsyncCore( DocumentsInitRequest request, RequestOptions? options = null, @@ -978,6 +1112,33 @@ public WithRawResponseTask UploadProxyAsync( ); } + /// + /// Default mode is synchronous and bounded: the response returns only after the transfer verified and committed (or failed). mode=async (connection sources only) answers 202 immediately and an in-process worker performs the transfer with leased, fenced retries; poll the document until ready/failed. The deployment import policy gates scheme, network range, and size; sources must declare a length. CloudPDF copies and owns the bytes — the source is never referenced in place. A 502 marks a retryable upstream failure: retry with the same idempotencyKey to resume the same document. URL sources are capabilities and never echoed back. Connection sources name operator-registered storage (bucket/prefix scope, allowed credential classes, and tenant bindings are deployment configuration); `revision` is provider-interpreted (S3 VersionId, GCS generation, Azure version id). + /// + /// + /// await client.Documents.ImportFromAsync( + /// new DocumentsImportFromRequest + /// { + /// TenantId = "tenantId", + /// Source = new DocumentsImportFromRequestSource( + /// new DocumentsImportFromRequestSource.Url( + /// new DocumentsImportFromRequestSourceUrl { Url = "url" } + /// ) + /// ), + /// } + /// ); + /// + public WithRawResponseTask ImportFromAsync( + DocumentsImportFromRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + ImportFromAsyncCore(request, options, cancellationToken) + ); + } + /// /// await client.Documents.InitAsync( /// new DocumentsInitRequest diff --git a/src/CloudPDF/Documents/IDocumentsClient.cs b/src/CloudPDF/Documents/IDocumentsClient.cs index 5d49855..65cd821 100644 --- a/src/CloudPDF/Documents/IDocumentsClient.cs +++ b/src/CloudPDF/Documents/IDocumentsClient.cs @@ -47,6 +47,15 @@ WithRawResponseTask UploadProxyAsync( CancellationToken cancellationToken = default ); + /// + /// Default mode is synchronous and bounded: the response returns only after the transfer verified and committed (or failed). mode=async (connection sources only) answers 202 immediately and an in-process worker performs the transfer with leased, fenced retries; poll the document until ready/failed. The deployment import policy gates scheme, network range, and size; sources must declare a length. CloudPDF copies and owns the bytes — the source is never referenced in place. A 502 marks a retryable upstream failure: retry with the same idempotencyKey to resume the same document. URL sources are capabilities and never echoed back. Connection sources name operator-registered storage (bucket/prefix scope, allowed credential classes, and tenant bindings are deployment configuration); `revision` is provider-interpreted (S3 VersionId, GCS generation, Azure version id). + /// + WithRawResponseTask ImportFromAsync( + DocumentsImportFromRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + WithRawResponseTask InitAsync( DocumentsInitRequest request, RequestOptions? options = null, diff --git a/src/CloudPDF/Documents/Requests/DocumentsImportFromRequest.cs b/src/CloudPDF/Documents/Requests/DocumentsImportFromRequest.cs new file mode 100644 index 0000000..eceb67b --- /dev/null +++ b/src/CloudPDF/Documents/Requests/DocumentsImportFromRequest.cs @@ -0,0 +1,38 @@ +using CloudPDF.Core; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFromRequest +{ + [JsonIgnore] + public required string TenantId { get; set; } + + [JsonPropertyName("source")] + public required DocumentsImportFromRequestSource Source { get; set; } + + [JsonPropertyName("expected")] + public DocumentsImportFromRequestExpected? Expected { get; set; } + + [JsonPropertyName("metadata")] + public Dictionary? Metadata { get; set; } + + [JsonPropertyName("idempotencyKey")] + public string? IdempotencyKey { get; set; } + + [JsonPropertyName("dedupMode")] + public DocumentsImportFromRequestDedupMode? DedupMode { get; set; } + + [JsonPropertyName("docId")] + public string? DocId { get; set; } + + [JsonPropertyName("mode")] + public DocumentsImportFromRequestMode? Mode { get; set; } + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Documents/Types/DocumentsImportFromRequestDedupMode.cs b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestDedupMode.cs new file mode 100644 index 0000000..e1fc0f3 --- /dev/null +++ b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestDedupMode.cs @@ -0,0 +1,123 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter( + typeof(DocumentsImportFromRequestDedupMode.DocumentsImportFromRequestDedupModeSerializer) +)] +[Serializable] +public readonly record struct DocumentsImportFromRequestDedupMode : IStringEnum +{ + public static readonly DocumentsImportFromRequestDedupMode AlwaysCreate = new( + Values.AlwaysCreate + ); + + public static readonly DocumentsImportFromRequestDedupMode ReuseExisting = new( + Values.ReuseExisting + ); + + public DocumentsImportFromRequestDedupMode(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static DocumentsImportFromRequestDedupMode FromCustom(string value) + { + return new DocumentsImportFromRequestDedupMode(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(DocumentsImportFromRequestDedupMode value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(DocumentsImportFromRequestDedupMode value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(DocumentsImportFromRequestDedupMode value) => + value.Value; + + public static explicit operator DocumentsImportFromRequestDedupMode(string value) => new(value); + + internal class DocumentsImportFromRequestDedupModeSerializer + : JsonConverter + { + public override DocumentsImportFromRequestDedupMode Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new DocumentsImportFromRequestDedupMode(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + DocumentsImportFromRequestDedupMode value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override DocumentsImportFromRequestDedupMode ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new DocumentsImportFromRequestDedupMode(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + DocumentsImportFromRequestDedupMode value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string AlwaysCreate = "always-create"; + + public const string ReuseExisting = "reuse-existing"; + } +} diff --git a/src/CloudPDF/Documents/Types/DocumentsImportFromRequestExpected.cs b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestExpected.cs new file mode 100644 index 0000000..db8f9f8 --- /dev/null +++ b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestExpected.cs @@ -0,0 +1,31 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFromRequestExpected : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("sizeBytes")] + public int? SizeBytes { get; set; } + + [JsonPropertyName("sha256")] + public string? Sha256 { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Documents/Types/DocumentsImportFromRequestMode.cs b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestMode.cs new file mode 100644 index 0000000..ae87bb1 --- /dev/null +++ b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestMode.cs @@ -0,0 +1,116 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter(typeof(DocumentsImportFromRequestMode.DocumentsImportFromRequestModeSerializer))] +[Serializable] +public readonly record struct DocumentsImportFromRequestMode : IStringEnum +{ + public static readonly DocumentsImportFromRequestMode Sync = new(Values.Sync); + + public static readonly DocumentsImportFromRequestMode Async = new(Values.Async); + + public DocumentsImportFromRequestMode(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static DocumentsImportFromRequestMode FromCustom(string value) + { + return new DocumentsImportFromRequestMode(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(DocumentsImportFromRequestMode value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(DocumentsImportFromRequestMode value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(DocumentsImportFromRequestMode value) => value.Value; + + public static explicit operator DocumentsImportFromRequestMode(string value) => new(value); + + internal class DocumentsImportFromRequestModeSerializer + : JsonConverter + { + public override DocumentsImportFromRequestMode Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new DocumentsImportFromRequestMode(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + DocumentsImportFromRequestMode value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override DocumentsImportFromRequestMode ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new DocumentsImportFromRequestMode(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + DocumentsImportFromRequestMode value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Sync = "sync"; + + public const string Async = "async"; + } +} diff --git a/src/CloudPDF/Documents/Types/DocumentsImportFromRequestSource.cs b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestSource.cs new file mode 100644 index 0000000..2a68934 --- /dev/null +++ b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestSource.cs @@ -0,0 +1,292 @@ +// ReSharper disable NullableWarningSuppressionIsUsed +// ReSharper disable InconsistentNaming + +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Nodes; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter(typeof(DocumentsImportFromRequestSource.JsonConverter))] +[Serializable] +public record DocumentsImportFromRequestSource +{ + internal DocumentsImportFromRequestSource(string type, object? value) + { + Kind = type; + Value = value; + } + + /// + /// Create an instance of DocumentsImportFromRequestSource with . + /// + public DocumentsImportFromRequestSource(DocumentsImportFromRequestSource.Url value) + { + Kind = "url"; + Value = value.Value; + } + + /// + /// Create an instance of DocumentsImportFromRequestSource with . + /// + public DocumentsImportFromRequestSource(DocumentsImportFromRequestSource.Connection value) + { + Kind = "connection"; + Value = value.Value; + } + + /// + /// Discriminant value + /// + [JsonPropertyName("kind")] + public string Kind { get; internal set; } + + /// + /// Discriminated union value + /// + public object? Value { get; internal set; } + + /// + /// Returns true if is "url" + /// + public bool IsUrl => Kind == "url"; + + /// + /// Returns true if is "connection" + /// + public bool IsConnection => Kind == "connection"; + + /// + /// Returns the value as a if is 'url', otherwise throws an exception. + /// + /// Thrown when is not 'url'. + public CloudPDF.DocumentsImportFromRequestSourceUrl AsUrl() => + IsUrl + ? (CloudPDF.DocumentsImportFromRequestSourceUrl)Value! + : throw new global::System.Exception( + "DocumentsImportFromRequestSource.Kind is not 'url'" + ); + + /// + /// Returns the value as a if is 'connection', otherwise throws an exception. + /// + /// Thrown when is not 'connection'. + public CloudPDF.DocumentsImportFromRequestSourceConnection AsConnection() => + IsConnection + ? (CloudPDF.DocumentsImportFromRequestSourceConnection)Value! + : throw new global::System.Exception( + "DocumentsImportFromRequestSource.Kind is not 'connection'" + ); + + public T Match( + Func onUrl, + Func onConnection, + Func onUnknown_ + ) + { + return Kind switch + { + "url" => onUrl(AsUrl()), + "connection" => onConnection(AsConnection()), + _ => onUnknown_(Kind, Value), + }; + } + + public void Visit( + Action onUrl, + Action onConnection, + Action onUnknown_ + ) + { + switch (Kind) + { + case "url": + onUrl(AsUrl()); + break; + case "connection": + onConnection(AsConnection()); + break; + default: + onUnknown_(Kind, Value); + break; + } + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryAsUrl(out CloudPDF.DocumentsImportFromRequestSourceUrl? value) + { + if (Kind == "url") + { + value = (CloudPDF.DocumentsImportFromRequestSourceUrl)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryAsConnection(out CloudPDF.DocumentsImportFromRequestSourceConnection? value) + { + if (Kind == "connection") + { + value = (CloudPDF.DocumentsImportFromRequestSourceConnection)Value!; + return true; + } + value = null; + return false; + } + + public override string ToString() => JsonUtils.Serialize(this); + + public static implicit operator DocumentsImportFromRequestSource( + DocumentsImportFromRequestSource.Url value + ) => new(value); + + public static implicit operator DocumentsImportFromRequestSource( + DocumentsImportFromRequestSource.Connection value + ) => new(value); + + [Serializable] + internal sealed class JsonConverter : JsonConverter + { + public override bool CanConvert(global::System.Type typeToConvert) => + typeof(DocumentsImportFromRequestSource).IsAssignableFrom(typeToConvert); + + public override DocumentsImportFromRequestSource Read( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonElement.ParseValue(ref reader); + if (!json.TryGetProperty("kind", out var discriminatorElement)) + { + throw new JsonException("Missing discriminator property 'kind'"); + } + if (discriminatorElement.ValueKind != JsonValueKind.String) + { + if (discriminatorElement.ValueKind == JsonValueKind.Null) + { + throw new JsonException("Discriminator property 'kind' is null"); + } + + throw new JsonException( + $"Discriminator property 'kind' is not a string, instead is {discriminatorElement.ToString()}" + ); + } + + var discriminator = + discriminatorElement.GetString() + ?? throw new JsonException("Discriminator property 'kind' is null"); + + // Strip the discriminant property to prevent it from leaking into AdditionalProperties + var jsonObject = System.Text.Json.Nodes.JsonObject.Create(json); + jsonObject?.Remove("kind"); + var jsonWithoutDiscriminator = + jsonObject != null ? JsonSerializer.SerializeToElement(jsonObject, options) : json; + + var value = discriminator switch + { + "url" => + jsonWithoutDiscriminator.Deserialize( + options + ) + ?? throw new JsonException( + "Failed to deserialize CloudPDF.DocumentsImportFromRequestSourceUrl" + ), + "connection" => + jsonWithoutDiscriminator.Deserialize( + options + ) + ?? throw new JsonException( + "Failed to deserialize CloudPDF.DocumentsImportFromRequestSourceConnection" + ), + _ => json.Deserialize(options), + }; + return new DocumentsImportFromRequestSource(discriminator, value); + } + + public override void Write( + Utf8JsonWriter writer, + DocumentsImportFromRequestSource value, + JsonSerializerOptions options + ) + { + JsonNode json = + value.Kind switch + { + "url" => JsonSerializer.SerializeToNode(value.Value, options), + "connection" => JsonSerializer.SerializeToNode(value.Value, options), + _ => JsonSerializer.SerializeToNode(value.Value, options), + } ?? new JsonObject(); + json["kind"] = value.Kind; + json.WriteTo(writer, options); + } + + public override DocumentsImportFromRequestSource ReadAsPropertyName( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new JsonException("The JSON property name could not be read as a string."); + return new DocumentsImportFromRequestSource(stringValue, stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + DocumentsImportFromRequestSource value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Kind); + } + } + + /// + /// Discriminated union type for url + /// + [Serializable] + public struct Url + { + public Url(CloudPDF.DocumentsImportFromRequestSourceUrl value) + { + Value = value; + } + + internal CloudPDF.DocumentsImportFromRequestSourceUrl Value { get; set; } + + public override string ToString() => Value.ToString() ?? "null"; + + public static implicit operator DocumentsImportFromRequestSource.Url( + CloudPDF.DocumentsImportFromRequestSourceUrl value + ) => new(value); + } + + /// + /// Discriminated union type for connection + /// + [Serializable] + public struct Connection + { + public Connection(CloudPDF.DocumentsImportFromRequestSourceConnection value) + { + Value = value; + } + + internal CloudPDF.DocumentsImportFromRequestSourceConnection Value { get; set; } + + public override string ToString() => Value.ToString() ?? "null"; + + public static implicit operator DocumentsImportFromRequestSource.Connection( + CloudPDF.DocumentsImportFromRequestSourceConnection value + ) => new(value); + } +} diff --git a/src/CloudPDF/Documents/Types/DocumentsImportFromRequestSourceConnection.cs b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestSourceConnection.cs new file mode 100644 index 0000000..865ab40 --- /dev/null +++ b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestSourceConnection.cs @@ -0,0 +1,34 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFromRequestSourceConnection : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("connectionId")] + public required string ConnectionId { get; set; } + + [JsonPropertyName("key")] + public required string Key { get; set; } + + [JsonPropertyName("revision")] + public string? Revision { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Documents/Types/DocumentsImportFromRequestSourceUrl.cs b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestSourceUrl.cs new file mode 100644 index 0000000..0bac93e --- /dev/null +++ b/src/CloudPDF/Documents/Types/DocumentsImportFromRequestSourceUrl.cs @@ -0,0 +1,28 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFromRequestSourceUrl : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("url")] + public required string Url { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Exceptions/BadGatewayError.cs b/src/CloudPDF/Exceptions/BadGatewayError.cs new file mode 100644 index 0000000..0f44a34 --- /dev/null +++ b/src/CloudPDF/Exceptions/BadGatewayError.cs @@ -0,0 +1,16 @@ +namespace CloudPDF; + +/// +/// This exception type will be thrown for any non-2XX API responses. +/// +[Serializable] +public class BadGatewayError( + DocumentsImportFrom502Response body, + CloudPDF.RawResponse? rawResponse = null +) : CloudPDFApiException("BadGatewayError", 502, body, rawResponse: rawResponse) +{ + /// + /// The body of the response that triggered the exception. + /// + public new DocumentsImportFrom502Response Body => body; +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom200Response.cs b/src/CloudPDF/Types/DocumentsImportFrom200Response.cs new file mode 100644 index 0000000..026b936 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom200Response.cs @@ -0,0 +1,31 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFrom200Response : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("tag")] + public required DocumentsImportFrom200ResponseTag Tag { get; set; } + + [JsonPropertyName("document")] + public required DocumentsImportFrom200ResponseDocument Document { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom200ResponseDocument.cs b/src/CloudPDF/Types/DocumentsImportFrom200ResponseDocument.cs new file mode 100644 index 0000000..a46a68e --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom200ResponseDocument.cs @@ -0,0 +1,64 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFrom200ResponseDocument : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("tenantId")] + public required string TenantId { get; set; } + + [JsonPropertyName("state")] + public required DocumentsImportFrom200ResponseDocumentState State { get; set; } + + [JsonPropertyName("baseSha")] + public string? BaseSha { get; set; } + + [JsonPropertyName("storageSizeBytes")] + public double? StorageSizeBytes { get; set; } + + [JsonPropertyName("metadata")] + public Dictionary? Metadata { get; set; } + + [JsonPropertyName("idempotencyKey")] + public string? IdempotencyKey { get; set; } + + [JsonPropertyName("failureReason")] + public string? FailureReason { get; set; } + + [JsonPropertyName("thumbnailState")] + public DocumentsImportFrom200ResponseDocumentThumbnailState? ThumbnailState { get; set; } + + [JsonPropertyName("thumbnailUrl")] + public string? ThumbnailUrl { get; set; } + + [JsonPropertyName("createdAt")] + public required double CreatedAt { get; set; } + + [JsonPropertyName("updatedAt")] + public required double UpdatedAt { get; set; } + + [JsonPropertyName("createdBy")] + public string? CreatedBy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom200ResponseDocumentState.cs b/src/CloudPDF/Types/DocumentsImportFrom200ResponseDocumentState.cs new file mode 100644 index 0000000..7c877b0 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom200ResponseDocumentState.cs @@ -0,0 +1,136 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter( + typeof(DocumentsImportFrom200ResponseDocumentState.DocumentsImportFrom200ResponseDocumentStateSerializer) +)] +[Serializable] +public readonly record struct DocumentsImportFrom200ResponseDocumentState : IStringEnum +{ + public static readonly DocumentsImportFrom200ResponseDocumentState Pending = new( + Values.Pending + ); + + public static readonly DocumentsImportFrom200ResponseDocumentState Ready = new(Values.Ready); + + public static readonly DocumentsImportFrom200ResponseDocumentState Failed = new(Values.Failed); + + public static readonly DocumentsImportFrom200ResponseDocumentState Deleting = new( + Values.Deleting + ); + + public DocumentsImportFrom200ResponseDocumentState(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static DocumentsImportFrom200ResponseDocumentState FromCustom(string value) + { + return new DocumentsImportFrom200ResponseDocumentState(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + DocumentsImportFrom200ResponseDocumentState value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + DocumentsImportFrom200ResponseDocumentState value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string(DocumentsImportFrom200ResponseDocumentState value) => + value.Value; + + public static explicit operator DocumentsImportFrom200ResponseDocumentState(string value) => + new(value); + + internal class DocumentsImportFrom200ResponseDocumentStateSerializer + : JsonConverter + { + public override DocumentsImportFrom200ResponseDocumentState Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new DocumentsImportFrom200ResponseDocumentState(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + DocumentsImportFrom200ResponseDocumentState value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override DocumentsImportFrom200ResponseDocumentState ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new DocumentsImportFrom200ResponseDocumentState(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + DocumentsImportFrom200ResponseDocumentState value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Pending = "pending"; + + public const string Ready = "ready"; + + public const string Failed = "failed"; + + public const string Deleting = "deleting"; + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom200ResponseDocumentThumbnailState.cs b/src/CloudPDF/Types/DocumentsImportFrom200ResponseDocumentThumbnailState.cs new file mode 100644 index 0000000..aaba749 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom200ResponseDocumentThumbnailState.cs @@ -0,0 +1,142 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter( + typeof(DocumentsImportFrom200ResponseDocumentThumbnailState.DocumentsImportFrom200ResponseDocumentThumbnailStateSerializer) +)] +[Serializable] +public readonly record struct DocumentsImportFrom200ResponseDocumentThumbnailState : IStringEnum +{ + public static readonly DocumentsImportFrom200ResponseDocumentThumbnailState Pending = new( + Values.Pending + ); + + public static readonly DocumentsImportFrom200ResponseDocumentThumbnailState Ready = new( + Values.Ready + ); + + public static readonly DocumentsImportFrom200ResponseDocumentThumbnailState Locked = new( + Values.Locked + ); + + public static readonly DocumentsImportFrom200ResponseDocumentThumbnailState Failed = new( + Values.Failed + ); + + public DocumentsImportFrom200ResponseDocumentThumbnailState(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static DocumentsImportFrom200ResponseDocumentThumbnailState FromCustom(string value) + { + return new DocumentsImportFrom200ResponseDocumentThumbnailState(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + DocumentsImportFrom200ResponseDocumentThumbnailState value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + DocumentsImportFrom200ResponseDocumentThumbnailState value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + DocumentsImportFrom200ResponseDocumentThumbnailState value + ) => value.Value; + + public static explicit operator DocumentsImportFrom200ResponseDocumentThumbnailState( + string value + ) => new(value); + + internal class DocumentsImportFrom200ResponseDocumentThumbnailStateSerializer + : JsonConverter + { + public override DocumentsImportFrom200ResponseDocumentThumbnailState Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new DocumentsImportFrom200ResponseDocumentThumbnailState(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + DocumentsImportFrom200ResponseDocumentThumbnailState value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override DocumentsImportFrom200ResponseDocumentThumbnailState ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new DocumentsImportFrom200ResponseDocumentThumbnailState(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + DocumentsImportFrom200ResponseDocumentThumbnailState value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Pending = "pending"; + + public const string Ready = "ready"; + + public const string Locked = "locked"; + + public const string Failed = "failed"; + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom200ResponseTag.cs b/src/CloudPDF/Types/DocumentsImportFrom200ResponseTag.cs new file mode 100644 index 0000000..2e7980e --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom200ResponseTag.cs @@ -0,0 +1,122 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter( + typeof(DocumentsImportFrom200ResponseTag.DocumentsImportFrom200ResponseTagSerializer) +)] +[Serializable] +public readonly record struct DocumentsImportFrom200ResponseTag : IStringEnum +{ + public static readonly DocumentsImportFrom200ResponseTag Imported = new(Values.Imported); + + public static readonly DocumentsImportFrom200ResponseTag Deduped = new(Values.Deduped); + + public static readonly DocumentsImportFrom200ResponseTag Accepted = new(Values.Accepted); + + public DocumentsImportFrom200ResponseTag(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static DocumentsImportFrom200ResponseTag FromCustom(string value) + { + return new DocumentsImportFrom200ResponseTag(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(DocumentsImportFrom200ResponseTag value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(DocumentsImportFrom200ResponseTag value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(DocumentsImportFrom200ResponseTag value) => value.Value; + + public static explicit operator DocumentsImportFrom200ResponseTag(string value) => new(value); + + internal class DocumentsImportFrom200ResponseTagSerializer + : JsonConverter + { + public override DocumentsImportFrom200ResponseTag Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new DocumentsImportFrom200ResponseTag(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + DocumentsImportFrom200ResponseTag value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override DocumentsImportFrom200ResponseTag ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new DocumentsImportFrom200ResponseTag(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + DocumentsImportFrom200ResponseTag value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Imported = "imported"; + + public const string Deduped = "deduped"; + + public const string Accepted = "accepted"; + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom202Response.cs b/src/CloudPDF/Types/DocumentsImportFrom202Response.cs new file mode 100644 index 0000000..65d43d0 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom202Response.cs @@ -0,0 +1,31 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFrom202Response : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("tag")] + public required DocumentsImportFrom202ResponseTag Tag { get; set; } + + [JsonPropertyName("document")] + public required DocumentsImportFrom202ResponseDocument Document { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom202ResponseDocument.cs b/src/CloudPDF/Types/DocumentsImportFrom202ResponseDocument.cs new file mode 100644 index 0000000..c1a5709 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom202ResponseDocument.cs @@ -0,0 +1,64 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFrom202ResponseDocument : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("tenantId")] + public required string TenantId { get; set; } + + [JsonPropertyName("state")] + public required DocumentsImportFrom202ResponseDocumentState State { get; set; } + + [JsonPropertyName("baseSha")] + public string? BaseSha { get; set; } + + [JsonPropertyName("storageSizeBytes")] + public double? StorageSizeBytes { get; set; } + + [JsonPropertyName("metadata")] + public Dictionary? Metadata { get; set; } + + [JsonPropertyName("idempotencyKey")] + public string? IdempotencyKey { get; set; } + + [JsonPropertyName("failureReason")] + public string? FailureReason { get; set; } + + [JsonPropertyName("thumbnailState")] + public DocumentsImportFrom202ResponseDocumentThumbnailState? ThumbnailState { get; set; } + + [JsonPropertyName("thumbnailUrl")] + public string? ThumbnailUrl { get; set; } + + [JsonPropertyName("createdAt")] + public required double CreatedAt { get; set; } + + [JsonPropertyName("updatedAt")] + public required double UpdatedAt { get; set; } + + [JsonPropertyName("createdBy")] + public string? CreatedBy { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom202ResponseDocumentState.cs b/src/CloudPDF/Types/DocumentsImportFrom202ResponseDocumentState.cs new file mode 100644 index 0000000..1722a14 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom202ResponseDocumentState.cs @@ -0,0 +1,136 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter( + typeof(DocumentsImportFrom202ResponseDocumentState.DocumentsImportFrom202ResponseDocumentStateSerializer) +)] +[Serializable] +public readonly record struct DocumentsImportFrom202ResponseDocumentState : IStringEnum +{ + public static readonly DocumentsImportFrom202ResponseDocumentState Pending = new( + Values.Pending + ); + + public static readonly DocumentsImportFrom202ResponseDocumentState Ready = new(Values.Ready); + + public static readonly DocumentsImportFrom202ResponseDocumentState Failed = new(Values.Failed); + + public static readonly DocumentsImportFrom202ResponseDocumentState Deleting = new( + Values.Deleting + ); + + public DocumentsImportFrom202ResponseDocumentState(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static DocumentsImportFrom202ResponseDocumentState FromCustom(string value) + { + return new DocumentsImportFrom202ResponseDocumentState(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + DocumentsImportFrom202ResponseDocumentState value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + DocumentsImportFrom202ResponseDocumentState value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string(DocumentsImportFrom202ResponseDocumentState value) => + value.Value; + + public static explicit operator DocumentsImportFrom202ResponseDocumentState(string value) => + new(value); + + internal class DocumentsImportFrom202ResponseDocumentStateSerializer + : JsonConverter + { + public override DocumentsImportFrom202ResponseDocumentState Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new DocumentsImportFrom202ResponseDocumentState(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + DocumentsImportFrom202ResponseDocumentState value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override DocumentsImportFrom202ResponseDocumentState ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new DocumentsImportFrom202ResponseDocumentState(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + DocumentsImportFrom202ResponseDocumentState value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Pending = "pending"; + + public const string Ready = "ready"; + + public const string Failed = "failed"; + + public const string Deleting = "deleting"; + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom202ResponseDocumentThumbnailState.cs b/src/CloudPDF/Types/DocumentsImportFrom202ResponseDocumentThumbnailState.cs new file mode 100644 index 0000000..1209a64 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom202ResponseDocumentThumbnailState.cs @@ -0,0 +1,142 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter( + typeof(DocumentsImportFrom202ResponseDocumentThumbnailState.DocumentsImportFrom202ResponseDocumentThumbnailStateSerializer) +)] +[Serializable] +public readonly record struct DocumentsImportFrom202ResponseDocumentThumbnailState : IStringEnum +{ + public static readonly DocumentsImportFrom202ResponseDocumentThumbnailState Pending = new( + Values.Pending + ); + + public static readonly DocumentsImportFrom202ResponseDocumentThumbnailState Ready = new( + Values.Ready + ); + + public static readonly DocumentsImportFrom202ResponseDocumentThumbnailState Locked = new( + Values.Locked + ); + + public static readonly DocumentsImportFrom202ResponseDocumentThumbnailState Failed = new( + Values.Failed + ); + + public DocumentsImportFrom202ResponseDocumentThumbnailState(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static DocumentsImportFrom202ResponseDocumentThumbnailState FromCustom(string value) + { + return new DocumentsImportFrom202ResponseDocumentThumbnailState(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==( + DocumentsImportFrom202ResponseDocumentThumbnailState value1, + string value2 + ) => value1.Value.Equals(value2); + + public static bool operator !=( + DocumentsImportFrom202ResponseDocumentThumbnailState value1, + string value2 + ) => !value1.Value.Equals(value2); + + public static explicit operator string( + DocumentsImportFrom202ResponseDocumentThumbnailState value + ) => value.Value; + + public static explicit operator DocumentsImportFrom202ResponseDocumentThumbnailState( + string value + ) => new(value); + + internal class DocumentsImportFrom202ResponseDocumentThumbnailStateSerializer + : JsonConverter + { + public override DocumentsImportFrom202ResponseDocumentThumbnailState Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new DocumentsImportFrom202ResponseDocumentThumbnailState(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + DocumentsImportFrom202ResponseDocumentThumbnailState value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override DocumentsImportFrom202ResponseDocumentThumbnailState ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new DocumentsImportFrom202ResponseDocumentThumbnailState(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + DocumentsImportFrom202ResponseDocumentThumbnailState value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Pending = "pending"; + + public const string Ready = "ready"; + + public const string Locked = "locked"; + + public const string Failed = "failed"; + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom202ResponseTag.cs b/src/CloudPDF/Types/DocumentsImportFrom202ResponseTag.cs new file mode 100644 index 0000000..6e33e26 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom202ResponseTag.cs @@ -0,0 +1,122 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[JsonConverter( + typeof(DocumentsImportFrom202ResponseTag.DocumentsImportFrom202ResponseTagSerializer) +)] +[Serializable] +public readonly record struct DocumentsImportFrom202ResponseTag : IStringEnum +{ + public static readonly DocumentsImportFrom202ResponseTag Imported = new(Values.Imported); + + public static readonly DocumentsImportFrom202ResponseTag Deduped = new(Values.Deduped); + + public static readonly DocumentsImportFrom202ResponseTag Accepted = new(Values.Accepted); + + public DocumentsImportFrom202ResponseTag(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static DocumentsImportFrom202ResponseTag FromCustom(string value) + { + return new DocumentsImportFrom202ResponseTag(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(DocumentsImportFrom202ResponseTag value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(DocumentsImportFrom202ResponseTag value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(DocumentsImportFrom202ResponseTag value) => value.Value; + + public static explicit operator DocumentsImportFrom202ResponseTag(string value) => new(value); + + internal class DocumentsImportFrom202ResponseTagSerializer + : JsonConverter + { + public override DocumentsImportFrom202ResponseTag Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new DocumentsImportFrom202ResponseTag(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + DocumentsImportFrom202ResponseTag value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override DocumentsImportFrom202ResponseTag ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new DocumentsImportFrom202ResponseTag(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + DocumentsImportFrom202ResponseTag value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Imported = "imported"; + + public const string Deduped = "deduped"; + + public const string Accepted = "accepted"; + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom400Response.cs b/src/CloudPDF/Types/DocumentsImportFrom400Response.cs new file mode 100644 index 0000000..8c716a1 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom400Response.cs @@ -0,0 +1,28 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFrom400Response : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("error")] + public required DocumentsImportFrom400ResponseError Error { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom400ResponseError.cs b/src/CloudPDF/Types/DocumentsImportFrom400ResponseError.cs new file mode 100644 index 0000000..5b55902 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom400ResponseError.cs @@ -0,0 +1,31 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFrom400ResponseError : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("code")] + public required string Code { get; set; } + + [JsonPropertyName("message")] + public required string Message { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom403Response.cs b/src/CloudPDF/Types/DocumentsImportFrom403Response.cs new file mode 100644 index 0000000..f1182d4 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom403Response.cs @@ -0,0 +1,28 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFrom403Response : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("error")] + public required DocumentsImportFrom403ResponseError Error { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom403ResponseError.cs b/src/CloudPDF/Types/DocumentsImportFrom403ResponseError.cs new file mode 100644 index 0000000..71d7ffd --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom403ResponseError.cs @@ -0,0 +1,31 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFrom403ResponseError : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("code")] + public required string Code { get; set; } + + [JsonPropertyName("message")] + public required string Message { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom502Response.cs b/src/CloudPDF/Types/DocumentsImportFrom502Response.cs new file mode 100644 index 0000000..7c22900 --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom502Response.cs @@ -0,0 +1,28 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFrom502Response : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("error")] + public required DocumentsImportFrom502ResponseError Error { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/CloudPDF/Types/DocumentsImportFrom502ResponseError.cs b/src/CloudPDF/Types/DocumentsImportFrom502ResponseError.cs new file mode 100644 index 0000000..17a682f --- /dev/null +++ b/src/CloudPDF/Types/DocumentsImportFrom502ResponseError.cs @@ -0,0 +1,31 @@ +using CloudPDF.Core; +using global::System.Text.Json; +using global::System.Text.Json.Serialization; + +namespace CloudPDF; + +[Serializable] +public record DocumentsImportFrom502ResponseError : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("code")] + public required string Code { get; set; } + + [JsonPropertyName("message")] + public required string Message { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +}